]> gcc.gnu.org Git - gcc.git/commitdiff
c-common.def (EXPR_STMT): Remove, moved to C++ frontend.
authorIan Lance Taylor <ian@airs.com>
Mon, 25 Apr 2005 19:03:41 +0000 (19:03 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Mon, 25 Apr 2005 19:03:41 +0000 (19:03 +0000)
./ * 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

14 files changed:
gcc/ChangeLog
gcc/c-common.def
gcc/c-common.h
gcc/c-dump.c
gcc/c-gimplify.c
gcc/c-objc-common.c
gcc/c-pretty-print.c
gcc/cp/ChangeLog
gcc/cp/cp-gimplify.c
gcc/cp/cp-tree.def
gcc/cp/cp-tree.h
gcc/cp/cxx-pretty-print.c
gcc/cp/dump.c
gcc/cp/lex.c

index 461598964d0f95a2690ca584af2a7a83c3182681..d99ba07d345e961983412eb588f0e8ee2fbec111 100644 (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.
index 4f34a70ac17d51c818968fed3039f3f5f233ccc1..bd6269409d2ef004f836b372f8a8b6a64bbb6c43 100644 (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
index 5c8fc18022af894c307aadf854fd10024e42e7df..5c9330b3c90ac3a602255621739bb3a4ed1183de 100644 (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];
index 1b1bb7f31c52ef88fc9598c755689830b9367754..a308ec98fb1d62730fcb30fb1c82625b8650718e 100644 (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;
     }
index 70db9f249a86f9b64108b907009072783ad15c24..a82c4a6562bbe2c0393e90bc7b25a28f9a0f7cd9 100644 (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;
     }
index 178f10fc2c60fafa3898a13134685d4c35b57def..0dc8f55ddfcb242d642883ff60cf159746aaed9e 100644 (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)
index 811a7bac15418652f6d3c67e5d60d00dfae0af92..699977a08c3a546d16d4b4eec3c2c7467ec758e3 100644 (file)
@@ -1910,40 +1910,16 @@ pp_c_expression (c_pretty_printer *pp, tree e)
 \f
 /* 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);
 }
 
 \f
index 74b00a10b66796cdb997ac63f63358062fdccdd4..09677e8f645bd56c5cdb538bb344ba00a0f98d8f 100644 (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
index 4d8880acb3b637656d0ac785403b69e796d32653..fc8c1af2d21422c986f2c9289a4ab1a7c7a666c9 100644 (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;
index 2c944de9197be51aba0a74eeb3eb33e088740f75..705517a2e4a88a9a22a558e1deed1c6f103b19fe 100644 (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.
index aba46f47d330eac9212ce1187821b36d9a47659a..05b28dde06fd6a4b59541418380ce16db6283e31 100644 (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.  */
index 2bffb735a26a985baa9e9cc90a6e07b401a1a803..0ad1e9a4025799be82577da38b1c348449223283 100644 (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);
index 20c7ace5e8cfbe7fbad95646c3a83e5b6f749b1f..6b93045e02f0ff2cafab06dc0d0f0da15ff766bb 100644 (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;
     }
index 9e39241d6e25798ef1468da12b96be975b0fac91..c5f21d1b195c11ed5e306c5201d843ff60f04f60 100644 (file)
@@ -320,7 +320,6 @@ bool
 cxx_init (void)
 {
   static const enum tree_code stmt_codes[] = {
-    c_common_stmt_codes,
     cp_stmt_codes
   };
 
This page took 0.090203 seconds and 5 git commands to generate.