c-common.def (EXPR_STMT): Remove, moved to C++ frontend.

./	* c-common.def (EXPR_STMT): Remove, moved to C++ frontend.
	* c-common.h (EXPR_STMT_EXPR): Don't define.
	(c_common_stmt_codes): Don't define.
	* c-dump.c (c_dump_tree): Remove EXPR_STMT case.
	* c-gimplify.c (gimplify_expr_stmt): Remove.
	(c_gimplify_expr): Remove EXPR_STMT case.
	* c-objc-common.c (c_objc_common_init): Remove stmt_codes and call
	to INIT_STATEMENT_CODES.
	* c-pretty-print.c (pp_c_statement): Just call dump_generic_node.
cp/
	* cp-tree.def: Add EXPR_STMT.
	* cp-tree.h (cp_stmt_codes): Add EXPR_STMT.
	(EXPR_STMT_EXPR): Define.
	* cp-gimplify.c: Include "flags.h".
	(gimplify_expr_stmt): New static function.
	(cp_gimplify_expr): Handle EXPR_STMT.
	* cxx-pretty-print.c (pp_cxx_statement): Use pp_cxx_expression
	rather than pp_expression.
	(pp_cxx_statement): Handle EXPR_STMT.
	* dump.c (cp_dump_tree): Handle EXPR_STMT.
	* lex.c (cxx_init): Don't use c_common_stmt_codes in stmt_codes
	initializer.

From-SVN: r98731
This commit is contained in:
Ian Lance Taylor 2005-04-25 19:03:41 +00:00 committed by Ian Lance Taylor
parent eca5a6a939
commit 934790cc67
14 changed files with 102 additions and 108 deletions

View File

@ -1,3 +1,15 @@
2005-04-25 Ian Lance Taylor <ian@airs.com>
* c-common.def (EXPR_STMT): Remove, moved to C++ frontend.
* c-common.h (EXPR_STMT_EXPR): Don't define.
(c_common_stmt_codes): Don't define.
* c-dump.c (c_dump_tree): Remove EXPR_STMT case.
* c-gimplify.c (gimplify_expr_stmt): Remove.
(c_gimplify_expr): Remove EXPR_STMT case.
* c-objc-common.c (c_objc_common_init): Remove stmt_codes and call
to INIT_STATEMENT_CODES.
* c-pretty-print.c (pp_c_statement): Just call dump_generic_node.
2005-04-25 Jan Hubicka <jh@suse.cz>
* tree-cfg.c (tree_duplicate_bb): Duplicate EH region too.

View File

@ -1,5 +1,5 @@
/* This file contains the definitions and documentation for the
additional tree codes used in the GNU C++ compiler (see tree.def
additional tree codes used in the GNU C compiler (see tree.def
for the standard codes).
Copyright (C) 1987, 1988, 1990, 1993, 1997, 1998,
1999, 2000, 2001, 2004, 2005 Free Software Foundation, Inc.
@ -22,12 +22,8 @@ along with GCC; see the file COPYING. If not, write to the Free
Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA. */
/* Tree nodes relevant to both C and C++. These were originally in
cp-tree.def in the cp subdir. */
/* Used to represent an expression statement. Use `EXPR_STMT_EXPR' to
obtain the expression. */
DEFTREECODE (EXPR_STMT, "expr_stmt", tcc_expression, 1)
/* Tree nodes used in the C frontend. These are also shared with the
C++ and Objective C frontends. */
/* A COMPOUND_LITERAL_EXPR represents a C99 compound literal. The
COMPOUND_LITERAL_EXPR_DECL_STMT is the a DECL_STMT containing the decl

View File

@ -708,10 +708,6 @@ extern void finish_file (void);
#define STATEMENT_LIST_HAS_LABEL(NODE) \
TREE_LANG_FLAG_3 (STATEMENT_LIST_CHECK (NODE))
/* EXPR_STMT accessor. This gives the expression associated with an
expression statement. */
#define EXPR_STMT_EXPR(NODE) TREE_OPERAND (EXPR_STMT_CHECK (NODE), 0)
/* COMPOUND_LITERAL_EXPR accessors. */
#define COMPOUND_LITERAL_EXPR_DECL_STMT(NODE) \
TREE_OPERAND (COMPOUND_LITERAL_EXPR_CHECK (NODE), 0)
@ -728,9 +724,6 @@ enum c_tree_code {
#undef DEFTREECODE
#define c_common_stmt_codes \
EXPR_STMT
/* TRUE if a code represents a statement. The front end init
langhook should take care of initialization of this array. */
extern bool statement_code_p[MAX_TREE_CODES];

View File

@ -54,11 +54,6 @@ c_dump_tree (void *dump_info, tree t)
dump_string (di, "bitfield");
break;
case EXPR_STMT:
dump_stmt (di, t);
dump_child ("expr", EXPR_STMT_EXPR (t));
break;
default:
break;
}

View File

@ -173,56 +173,11 @@ c_build_bind_expr (tree block, tree body)
return bind;
}
/* Gimplify an EXPR_STMT node.
STMT is the statement node.
PRE_P points to the list where side effects that must happen before
STMT should be stored.
POST_P points to the list where side effects that must happen after
STMT should be stored. */
static enum gimplify_status
gimplify_expr_stmt (tree *stmt_p)
{
tree stmt = EXPR_STMT_EXPR (*stmt_p);
if (stmt == error_mark_node)
stmt = NULL;
/* Gimplification of a statement expression will nullify the
statement if all its side effects are moved to *PRE_P and *POST_P.
In this case we will not want to emit the gimplified statement.
However, we may still want to emit a warning, so we do that before
gimplification. */
if (stmt && (extra_warnings || warn_unused_value))
{
if (!TREE_SIDE_EFFECTS (stmt))
{
if (!IS_EMPTY_STMT (stmt)
&& !VOID_TYPE_P (TREE_TYPE (stmt))
&& !TREE_NO_WARNING (stmt))
warning (0, "statement with no effect");
}
else if (warn_unused_value)
warn_if_unused_value (stmt, input_location);
}
if (stmt == NULL_TREE)
stmt = alloc_stmt_list ();
*stmt_p = stmt;
return GS_OK;
}
/* Gimplification of expression trees. */
/* Gimplify a C99 compound literal expression. This just means adding the
DECL_EXPR before the current EXPR_STMT and using its anonymous decl
instead. */
/* Gimplify a C99 compound literal expression. This just means adding
the DECL_EXPR before the current statement and using its anonymous
decl instead. */
static enum gimplify_status
gimplify_compound_literal_expr (tree *expr_p, tree *pre_p)
@ -266,9 +221,6 @@ c_gimplify_expr (tree *expr_p, tree *pre_p, tree *post_p ATTRIBUTE_UNUSED)
case COMPOUND_LITERAL_EXPR:
return gimplify_compound_literal_expr (expr_p, pre_p);
case EXPR_STMT:
return gimplify_expr_stmt (expr_p);
default:
return GS_UNHANDLED;
}

View File

@ -124,12 +124,6 @@ c_warn_unused_global_decl (tree decl)
bool
c_objc_common_init (void)
{
static const enum tree_code stmt_codes[] = {
c_common_stmt_codes
};
INIT_STATEMENT_CODES (stmt_codes);
c_init_decl_processing ();
if (c_common_init () == false)

View File

@ -1910,40 +1910,16 @@ pp_c_expression (c_pretty_printer *pp, tree e)
/* Statements. */
/* statement:
labeled-statement
compound-statement
expression-statement
selection-statement
iteration-statement
jump-statement */
void
pp_c_statement (c_pretty_printer *pp, tree stmt)
{
enum tree_code code;
if (stmt == NULL)
return;
if (pp_needs_newline (pp))
pp_newline_and_indent (pp, 0);
code = TREE_CODE (stmt);
switch (code)
{
/* expression-statement:
expression(opt) ; */
case EXPR_STMT:
pp_expression (pp, EXPR_STMT_EXPR (stmt));
pp_c_semicolon (pp);
pp_needs_newline (pp) = true;
break;
default:
dump_generic_node (pp_base (pp), stmt, pp_indentation (pp), 0, true);
break;
}
dump_generic_node (pp_base (pp), stmt, pp_indentation (pp), 0, true);
}

View File

@ -1,3 +1,18 @@
2005-04-25 Ian Lance Taylor <ian@airs.com>
* cp-tree.def: Add EXPR_STMT.
* cp-tree.h (cp_stmt_codes): Add EXPR_STMT.
(EXPR_STMT_EXPR): Define.
* cp-gimplify.c: Include "flags.h".
(gimplify_expr_stmt): New static function.
(cp_gimplify_expr): Handle EXPR_STMT.
* cxx-pretty-print.c (pp_cxx_statement): Use pp_cxx_expression
rather than pp_expression.
(pp_cxx_statement): Handle EXPR_STMT.
* dump.c (cp_dump_tree): Handle EXPR_STMT.
* lex.c (cxx_init): Don't use c_common_stmt_codes in stmt_codes
initializer.
2005-04-25 Andrew Pinski <pinskia@physics.uc.edu>
PR C++/21188

View File

@ -31,6 +31,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "tree-gimple.h"
#include "hashtab.h"
#include "pointer-set.h"
#include "flags.h"
/* Local declarations. */
@ -338,6 +339,41 @@ gimplify_switch_stmt (tree *stmt_p)
*stmt_p = finish_bc_block (bc_break, break_block, *stmt_p);
}
/* Gimplify an EXPR_STMT node. */
static void
gimplify_expr_stmt (tree *stmt_p)
{
tree stmt = EXPR_STMT_EXPR (*stmt_p);
if (stmt == error_mark_node)
stmt = NULL;
/* Gimplification of a statement expression will nullify the
statement if all its side effects are moved to *PRE_P and *POST_P.
In this case we will not want to emit the gimplified statement.
However, we may still want to emit a warning, so we do that before
gimplification. */
if (stmt && (extra_warnings || warn_unused_value))
{
if (!TREE_SIDE_EFFECTS (stmt))
{
if (!IS_EMPTY_STMT (stmt)
&& !VOID_TYPE_P (TREE_TYPE (stmt))
&& !TREE_NO_WARNING (stmt))
warning (0, "statement with no effect");
}
else if (warn_unused_value)
warn_if_unused_value (stmt, input_location);
}
if (stmt == NULL_TREE)
stmt = alloc_stmt_list ();
*stmt_p = stmt;
}
/* Gimplify initialization from an AGGR_INIT_EXPR. */
static void
@ -516,6 +552,11 @@ cp_gimplify_expr (tree *expr_p, tree *pre_p, tree *post_p)
ret = GS_ALL_DONE;
break;
case EXPR_STMT:
gimplify_expr_stmt (expr_p);
ret = GS_OK;
break;
default:
ret = c_gimplify_expr (expr_p, pre_p, post_p);
break;

View File

@ -305,6 +305,10 @@ DEFTREECODE (CONTINUE_STMT, "continue_stmt", tcc_statement, 0)
SWITCH_STMT_COND, SWITCH_STMT_BODY and SWITCH_STMT_TYPE, respectively. */
DEFTREECODE (SWITCH_STMT, "switch_stmt", tcc_statement, 3)
/* Used to represent an expression statement. Use `EXPR_STMT_EXPR' to
obtain the expression. */
DEFTREECODE (EXPR_STMT, "expr_stmt", tcc_expression, 1)
DEFTREECODE (TAG_DEFN, "tag_defn", tcc_expression, 0)
/* Template instantiation level node.

View File

@ -852,7 +852,7 @@ enum cplus_tree_code {
EH_SPEC_BLOCK, USING_STMT, TAG_DEFN, \
IF_STMT, CLEANUP_STMT, FOR_STMT, \
WHILE_STMT, DO_STMT, BREAK_STMT, \
CONTINUE_STMT, SWITCH_STMT
CONTINUE_STMT, SWITCH_STMT, EXPR_STMT
enum languages { lang_c, lang_cplusplus, lang_java };
/* Macros to make error reporting functions' lives easier. */
@ -2949,6 +2949,10 @@ struct lang_decl GTY(())
/* STMT_EXPR accessor. */
#define STMT_EXPR_STMT(NODE) TREE_OPERAND (STMT_EXPR_CHECK (NODE), 0)
/* EXPR_STMT accessor. This gives the expression associated with an
expression statement. */
#define EXPR_STMT_EXPR(NODE) TREE_OPERAND (EXPR_STMT_CHECK (NODE), 0)
/* An enumeration of the kind of tags that C++ accepts. */
enum tag_types {
none_type = 0, /* Not a tag type. */

View File

@ -1587,7 +1587,7 @@ pp_cxx_statement (cxx_pretty_printer *pp, tree t)
pp_cxx_identifier (pp, "switch");
pp_space (pp);
pp_cxx_left_paren (pp);
pp_expression (pp, SWITCH_STMT_COND (t));
pp_cxx_expression (pp, SWITCH_STMT_COND (t));
pp_cxx_right_paren (pp);
pp_indentation (pp) += 3;
pp_needs_newline (pp) = true;
@ -1604,7 +1604,7 @@ pp_cxx_statement (cxx_pretty_printer *pp, tree t)
pp_cxx_identifier (pp, "while");
pp_space (pp);
pp_cxx_left_paren (pp);
pp_expression (pp, WHILE_COND (t));
pp_cxx_expression (pp, WHILE_COND (t));
pp_cxx_right_paren (pp);
pp_newline_and_indent (pp, 3);
pp_cxx_statement (pp, WHILE_BODY (t));
@ -1620,7 +1620,7 @@ pp_cxx_statement (cxx_pretty_printer *pp, tree t)
pp_cxx_identifier (pp, "while");
pp_space (pp);
pp_cxx_left_paren (pp);
pp_expression (pp, DO_COND (t));
pp_cxx_expression (pp, DO_COND (t));
pp_cxx_right_paren (pp);
pp_cxx_semicolon (pp);
pp_needs_newline (pp) = true;
@ -1637,12 +1637,12 @@ pp_cxx_statement (cxx_pretty_printer *pp, tree t)
pp_needs_newline (pp) = false;
pp_cxx_whitespace (pp);
if (FOR_COND (t))
pp_expression (pp, FOR_COND (t));
pp_cxx_expression (pp, FOR_COND (t));
pp_cxx_semicolon (pp);
pp_needs_newline (pp) = false;
pp_cxx_whitespace (pp);
if (FOR_EXPR (t))
pp_expression (pp, FOR_EXPR (t));
pp_cxx_expression (pp, FOR_EXPR (t));
pp_cxx_right_paren (pp);
pp_newline_and_indent (pp, 3);
pp_cxx_statement (pp, FOR_BODY (t));
@ -1661,6 +1661,14 @@ pp_cxx_statement (cxx_pretty_printer *pp, tree t)
pp_needs_newline (pp) = true;
break;
/* expression-statement:
expression(opt) ; */
case EXPR_STMT:
pp_cxx_expression (pp, EXPR_STMT_EXPR (t));
pp_cxx_semicolon (pp);
pp_needs_newline (pp) = true;
break;
case CLEANUP_STMT:
pp_cxx_identifier (pp, "try");
pp_newline_and_indent (pp, 2);

View File

@ -459,6 +459,11 @@ cp_dump_tree (void* dump_info, tree t)
dump_child ("stmt", STMT_EXPR_STMT (t));
break;
case EXPR_STMT:
dump_stmt (di, t);
dump_child ("expr", EXPR_STMT_EXPR (t));
break;
default:
break;
}

View File

@ -320,7 +320,6 @@ bool
cxx_init (void)
{
static const enum tree_code stmt_codes[] = {
c_common_stmt_codes,
cp_stmt_codes
};