summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2005-04-25 19:03:41 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2005-04-25 19:03:41 +0000
commit7219fab5f2729f3e4a2e67f0dbaa30b8c3af4c18 (patch)
tree04c6f7b2baf3f9d03ae1167e9d3db012d53a4e00
parentd34440fb1399385426c75bbb66b92fc38d5980ec (diff)
downloadgcc-7219fab5f2729f3e4a2e67f0dbaa30b8c3af4c18.tar.gz
./
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@98731 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog12
-rw-r--r--gcc/c-common.def10
-rw-r--r--gcc/c-common.h7
-rw-r--r--gcc/c-dump.c5
-rw-r--r--gcc/c-gimplify.c54
-rw-r--r--gcc/c-objc-common.c6
-rw-r--r--gcc/c-pretty-print.c26
-rw-r--r--gcc/cp/ChangeLog15
-rw-r--r--gcc/cp/cp-gimplify.c41
-rw-r--r--gcc/cp/cp-tree.def4
-rw-r--r--gcc/cp/cp-tree.h6
-rw-r--r--gcc/cp/cxx-pretty-print.c18
-rw-r--r--gcc/cp/dump.c5
-rw-r--r--gcc/cp/lex.c1
14 files changed, 102 insertions, 108 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 461598964d0..d99ba07d345 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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.
diff --git a/gcc/c-common.def b/gcc/c-common.def
index 4f34a70ac17..bd6269409d2 100644
--- a/gcc/c-common.def
+++ b/gcc/c-common.def
@@ -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
diff --git a/gcc/c-common.h b/gcc/c-common.h
index 5c8fc18022a..5c9330b3c90 100644
--- a/gcc/c-common.h
+++ b/gcc/c-common.h
@@ -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];
diff --git a/gcc/c-dump.c b/gcc/c-dump.c
index 1b1bb7f31c5..a308ec98fb1 100644
--- a/gcc/c-dump.c
+++ b/gcc/c-dump.c
@@ -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;
}
diff --git a/gcc/c-gimplify.c b/gcc/c-gimplify.c
index 70db9f249a8..a82c4a6562b 100644
--- a/gcc/c-gimplify.c
+++ b/gcc/c-gimplify.c
@@ -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;
}
diff --git a/gcc/c-objc-common.c b/gcc/c-objc-common.c
index 178f10fc2c6..0dc8f55ddfc 100644
--- a/gcc/c-objc-common.c
+++ b/gcc/c-objc-common.c
@@ -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)
diff --git a/gcc/c-pretty-print.c b/gcc/c-pretty-print.c
index 811a7bac154..699977a08c3 100644
--- a/gcc/c-pretty-print.c
+++ b/gcc/c-pretty-print.c
@@ -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);
}
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 74b00a10b66..09677e8f645 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index 4d8880acb3b..fc8c1af2d21 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -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;
diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def
index 2c944de9197..705517a2e4a 100644
--- a/gcc/cp/cp-tree.def
+++ b/gcc/cp/cp-tree.def
@@ -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.
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index aba46f47d33..05b28dde06f 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -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. */
diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c
index 2bffb735a26..0ad1e9a4025 100644
--- a/gcc/cp/cxx-pretty-print.c
+++ b/gcc/cp/cxx-pretty-print.c
@@ -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);
diff --git a/gcc/cp/dump.c b/gcc/cp/dump.c
index 20c7ace5e8c..6b93045e02f 100644
--- a/gcc/cp/dump.c
+++ b/gcc/cp/dump.c
@@ -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;
}
diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c
index 9e39241d6e2..c5f21d1b195 100644
--- a/gcc/cp/lex.c
+++ b/gcc/cp/lex.c
@@ -320,7 +320,6 @@ bool
cxx_init (void)
{
static const enum tree_code stmt_codes[] = {
- c_common_stmt_codes,
cp_stmt_codes
};