c-common.h (lang_statement_code_p): Remove declaration.
authorSteven Bosscher <steven@gcc.gnu.org>
Thu, 10 Apr 2003 08:07:13 +0000 (08:07 +0000)
committerSteven Bosscher <steven@gcc.gnu.org>
Thu, 10 Apr 2003 08:07:13 +0000 (08:07 +0000)
2003-04-09  Steven Bosscher  <steven@gcc.gnu.org>

* c-common.h (lang_statement_code_p): Remove declaration.
(statement_code_p): Ditto.
(c_common_stmt_codes): Define; list of c-common statement codes.
(statement_code_p): New extern declaration.
(STATEMENT_CODE_P): Define.
(INIT_STATEMENT_CODES): Define.
* c-common.c (statement_code_p): Kill the function, declare
as an array of bools instead.
(lang_statement_code_p): Remove.
(walk_stmt_tree): Use STATEMENT_CODE_P not statement_code_p.
(c_safe_from_p): Ditto.
* c-objc-common.c (c_objc_common_init): Use INIT_STATEMENT_CODES
to initialize the statement_code_p array.
* tree-inline.c (walk_tree): Use STATEMENT_CODE_P instead of
statement_code_p.
(copy_tree_r): Ditto.
* cp/cp-tree.h (cp_stmt_codes): Define; list of C++ specific
statement tree codes.
* cp/lex.c (cxx_init): Add missing print line break.  Use
INIT_STATEMENT_CODES to initialize the statement_code_p array.
* cp/parser.c (cp_parser_statement): Use STATEMENT_CODE_P
instead of statement_code_p.
* cp/pt.c (tsubst_expr): Ditto.
* cp/tree.c (verify_stmt_tree_r): Ditto.
(cp_statement_code_p): Remove.
(init_tree): Don't set lang_statement_code_p, it's gone.

From-SVN: r65422

gcc/ChangeLog
gcc/c-common.c
gcc/c-common.h
gcc/c-objc-common.c
gcc/cp/cp-tree.h
gcc/cp/lex.c
gcc/cp/parser.c
gcc/cp/pt.c
gcc/cp/tree.c
gcc/tree-inline.c

index 8110f48c90a0c544686f181b3c48071d002faf02..b54a0466ceb6e454a9157ee40a1b12a7fb8162b5 100644 (file)
@@ -1,3 +1,32 @@
+2003-04-09  Steven Bosscher  <steven@gcc.gnu.org>
+
+       * c-common.h (lang_statement_code_p): Remove declaration.
+       (statement_code_p): Ditto.
+       (c_common_stmt_codes): Define; list of c-common statement codes.
+       (statement_code_p): New extern declaration.
+       (STATEMENT_CODE_P): Define.
+       (INIT_STATEMENT_CODES): Define.
+       * c-common.c (statement_code_p): Kill the function, declare
+       as an array of bools instead.
+       (lang_statement_code_p): Remove.
+       (walk_stmt_tree): Use STATEMENT_CODE_P not statement_code_p.
+       (c_safe_from_p): Ditto.
+       * c-objc-common.c (c_objc_common_init): Use INIT_STATEMENT_CODES
+       to initialize the statement_code_p array.
+       * tree-inline.c (walk_tree): Use STATEMENT_CODE_P instead of
+       statement_code_p.
+       (copy_tree_r): Ditto.
+       * cp/cp-tree.h (cp_stmt_codes): Define; list of C++ specific
+       statement tree codes.
+       * cp/lex.c (cxx_init): Add missing print line break.  Use
+       INIT_STATEMENT_CODES to initialize the statement_code_p array.
+       * cp/parser.c (cp_parser_statement): Use STATEMENT_CODE_P
+       instead of statement_code_p.
+       * cp/pt.c (tsubst_expr): Ditto.
+       * cp/tree.c (verify_stmt_tree_r): Ditto.
+       (cp_statement_code_p): Remove.
+       (init_tree): Don't set lang_statement_code_p, it's gone.
+
 2003-04-09  Dan Nicolaescu  <dann@ics.uci.edu>
            Zack Weinberg  <zack@codesourcery.com>
 
index 65322df1c8d98696545e5eb8330dc7be26416eb4..7048d9a61002f3539a0eede2bdc36be34e998fa0 100644 (file)
@@ -187,6 +187,11 @@ enum c_language_kind c_language;
 
 tree c_global_trees[CTI_MAX];
 
+/* TRUE if a code represents a statement.  The front end init
+   langhook should take care of initialization of this array.  */
+
+bool statement_code_p[MAX_TREE_CODES];
+
 /* Nonzero if we can read a PCH file now.  */
 
 int allow_pch = 1;
@@ -682,10 +687,6 @@ tree *ridpointers;
 
 tree (*make_fname_decl)                PARAMS ((tree, int));
 
-/* If non-NULL, the address of a language-specific function that
-   returns 1 for language-specific statement codes.  */
-int (*lang_statement_code_p)           PARAMS ((enum tree_code));
-
 /* If non-NULL, the address of a language-specific function that takes
    any action required right before expand_function_end is called.  */
 void (*lang_expand_function_end)       PARAMS ((void));
@@ -3927,41 +3928,6 @@ expand_tree_builtin (function, params, coerced_params)
   return NULL_TREE;
 }
 
-/* Returns nonzero if CODE is the code for a statement.  */
-
-int
-statement_code_p (code)
-     enum tree_code code;
-{
-  switch (code)
-    {
-    case CLEANUP_STMT:
-    case EXPR_STMT:
-    case COMPOUND_STMT:
-    case DECL_STMT:
-    case IF_STMT:
-    case FOR_STMT:
-    case WHILE_STMT:
-    case DO_STMT:
-    case RETURN_STMT:
-    case BREAK_STMT:
-    case CONTINUE_STMT:
-    case SCOPE_STMT:
-    case SWITCH_STMT:
-    case GOTO_STMT:
-    case LABEL_STMT:
-    case ASM_STMT:
-    case FILE_STMT:
-    case CASE_LABEL:
-      return 1;
-
-    default:
-      if (lang_statement_code_p)
-       return (*lang_statement_code_p) (code);
-      return 0;
-    }
-}
-
 /* Walk the statement tree, rooted at *tp.  Apply FUNC to all the
    sub-trees of *TP in a pre-order traversal.  FUNC is called with the
    DATA and the address of each sub-tree.  If FUNC returns a non-NULL
@@ -3997,7 +3963,7 @@ walk_stmt_tree (tp, func, data)
     return NULL_TREE;
 
   /* Skip subtrees below non-statement nodes.  */
-  if (!statement_code_p (TREE_CODE (*tp)))
+  if (!STATEMENT_CODE_P (TREE_CODE (*tp)))
     return NULL_TREE;
 
   /* Call the function.  */
@@ -4011,7 +3977,7 @@ walk_stmt_tree (tp, func, data)
   /* FUNC may have modified the tree, recheck that we're looking at a
      statement node.  */
   code = TREE_CODE (*tp);
-  if (!statement_code_p (code))
+  if (!STATEMENT_CODE_P (code))
     return NULL_TREE;
 
   /* Visit the subtrees unless FUNC decided that there was nothing
@@ -4386,7 +4352,7 @@ c_safe_from_p (target, exp)
     }
 
   /* For any statement, we must follow the statement-chain.  */
-  if (statement_code_p (TREE_CODE (exp)) && TREE_CHAIN (exp))
+  if (STATEMENT_CODE_P (TREE_CODE (exp)) && TREE_CHAIN (exp))
     return safe_from_p (target, TREE_CHAIN (exp), /*top_p=*/0);
 
   /* Assume everything else is safe.  */
index 20c7c394aa0e9a4025b55b397e7307f64022836b..ed67ce6f7d4b0862ab99e16284a2f2488964705e 100644 (file)
@@ -305,7 +305,6 @@ struct c_language_function GTY(()) {
 
 /* Language-specific hooks.  */
 
-extern int (*lang_statement_code_p)             PARAMS ((enum tree_code));
 extern void (*lang_expand_stmt)                 PARAMS ((tree));
 extern void (*lang_expand_decl_stmt)            PARAMS ((tree));
 extern void (*lang_expand_function_end)         PARAMS ((void));
@@ -326,7 +325,6 @@ extern void add_decl_stmt                       PARAMS ((tree));
 extern tree add_scope_stmt                      PARAMS ((int, int));
 extern void finish_stmt_tree                    PARAMS ((tree *));
 
-extern int statement_code_p                     PARAMS ((enum tree_code));
 extern tree walk_stmt_tree                     PARAMS ((tree *,
                                                         walk_tree_fn,
                                                         void *));
@@ -1152,6 +1150,28 @@ enum c_tree_code {
 
 #undef DEFTREECODE
 
+#define c_common_stmt_codes                            \
+   CLEANUP_STMT,       EXPR_STMT,      COMPOUND_STMT,  \
+   DECL_STMT,          IF_STMT,        FOR_STMT,       \
+   WHILE_STMT,         DO_STMT,        RETURN_STMT,    \
+   BREAK_STMT,         CONTINUE_STMT,  SCOPE_STMT,     \
+   SWITCH_STMT,                GOTO_STMT,      LABEL_STMT,     \
+   ASM_STMT,           FILE_STMT,      CASE_LABEL
+
+/* 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];
+
+#define STATEMENT_CODE_P(CODE) statement_code_p[(int) (CODE)]
+
+#define INIT_STATEMENT_CODES(STMT_CODES)                       \
+  do {                                                         \
+    unsigned int i;                                            \
+    memset (&statement_code_p, 0, sizeof (statement_code_p));  \
+    for (i = 0; i < ARRAY_SIZE (STMT_CODES); i++)              \
+      statement_code_p[STMT_CODES[i]] = true;                  \
+  } while (0)
+
 extern void genrtl_do_pushlevel                 PARAMS ((void));
 extern void genrtl_goto_stmt                    PARAMS ((tree));
 extern void genrtl_expr_stmt                    PARAMS ((tree));
index e097527e3906b199c1c3b2ef5f1828eb639074db..32b894b4552a582f56666c5aecb11767692fb16e 100644 (file)
@@ -244,6 +244,12 @@ c_warn_unused_global_decl (decl)
 bool
 c_objc_common_init ()
 {
+  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 2986d6b6ae3d6a2ba10135ce7490b8d484b79b3e..0e9a201cc91b8297a4e099de95d637878ca8810d 100644 (file)
@@ -902,6 +902,10 @@ enum cplus_tree_code {
 };
 #undef DEFTREECODE
 
+#define cp_stmt_codes                                  \
+   CTOR_INITIALIZER,   TRY_BLOCK,      HANDLER,        \
+   EH_SPEC_BLOCK,      USING_STMT,     TAG_DEFN
+
 enum languages { lang_c, lang_cplusplus, lang_java };
 
 /* Macros to make error reporting functions' lives easier.  */
index 6433f2b1e0bf6dd69fe94c6741ac78c97aa6d34e..617be82e82b34d489c1333055502857dfd29ab69 100644 (file)
@@ -401,7 +401,7 @@ init_cp_pragma ()
   c_register_pragma ("GCC", "implementation", handle_pragma_implementation);
   c_register_pragma ("GCC", "java_exceptions", handle_pragma_java_exceptions);
 }
-
+\f
 /* Initialize the C++ front end.  This function is very sensitive to
    the exact order that things are done here.  It would be nice if the
    initialization done by this routine were moved to its subroutines,
@@ -409,6 +409,13 @@ init_cp_pragma ()
 bool
 cxx_init (void)
 {
+  static const enum tree_code stmt_codes[] = {
+    c_common_stmt_codes,
+    cp_stmt_codes
+  };
+
+  INIT_STATEMENT_CODES (stmt_codes);
+
   input_filename = "<internal>";
 
   init_reswords ();
index 8cc46f98325b128860fe066f661417f887450bbc..8f992c58327b188bc85177e91251ba9efedd1b1d 100644 (file)
@@ -5660,7 +5660,7 @@ cp_parser_statement (cp_parser* parser)
     }
 
   /* Set the line number for the statement.  */
-  if (statement && statement_code_p (TREE_CODE (statement)))
+  if (statement && STATEMENT_CODE_P (TREE_CODE (statement)))
     STMT_LINENO (statement) = statement_line_number;
 }
 
index b5ea239c51e15597775cb2564688c23a4ff60021..b37332953ef8b0755d06a397ae0a2c238e5f28aa 100644 (file)
@@ -7569,7 +7569,7 @@ tsubst_expr (t, args, complain, in_decl)
   if (processing_template_decl)
     return tsubst_copy (t, args, complain, in_decl);
 
-  if (!statement_code_p (TREE_CODE (t)))
+  if (!STATEMENT_CODE_P (TREE_CODE (t)))
     return tsubst_copy_and_build (t, args, complain, in_decl);
     
   switch (TREE_CODE (t))
index 97d297a8c31d093d58a93a9c7a55b94d5744cb6e..edb4ca06a4e9a6ae53945d57bbaea5d5598e68b8 100644 (file)
@@ -49,7 +49,6 @@ static tree build_target_expr PARAMS ((tree, tree));
 static tree count_trees_r PARAMS ((tree *, int *, void *));
 static tree verify_stmt_tree_r PARAMS ((tree *, int *, void *));
 static tree find_tree_r PARAMS ((tree *, int *, void *));
-extern int cp_statement_code_p PARAMS ((enum tree_code));
 
 static tree handle_java_interface_attribute PARAMS ((tree *, tree, tree, int, bool *));
 static tree handle_com_interface_attribute PARAMS ((tree *, tree, tree, int, bool *));
@@ -1119,27 +1118,6 @@ is_aggr_type_2 (t1, t2)
     return 0;
   return IS_AGGR_TYPE (t1) && IS_AGGR_TYPE (t2);
 }
-
-/* Returns nonzero if CODE is the code for a statement.  */
-
-int
-cp_statement_code_p (code)
-     enum tree_code code;
-{
-  switch (code)
-    {
-    case CTOR_INITIALIZER:
-    case TRY_BLOCK:
-    case HANDLER:
-    case EH_SPEC_BLOCK:
-    case USING_STMT:
-    case TAG_DEFN:
-      return 1;
-
-    default:
-      return 0;
-    }
-}
 \f
 #define PRINT_RING_SIZE 4
 
@@ -1275,7 +1253,7 @@ verify_stmt_tree_r (tp, walk_subtrees, data)
   htab_t *statements = (htab_t *) data;
   void **slot;
 
-  if (!statement_code_p (TREE_CODE (t)))
+  if (!STATEMENT_CODE_P (TREE_CODE (t)))
     return NULL_TREE;
 
   /* If this statement is already present in the hash table, then
@@ -2406,7 +2384,6 @@ cp_end_inlining (fn)
 void
 init_tree ()
 {
-  lang_statement_code_p = cp_statement_code_p;
   list_hash_table = htab_create_ggc (31, list_hash, list_hash_eq, NULL);
 }
 
index be72b59c213ab54876ed1f09be19109201133dd7..0131952c6a28e0830416dcc5949be95401389aa8 100644 (file)
@@ -1588,7 +1588,7 @@ walk_tree (tp, func, data, htab_)
      interesting below this point in the tree.  */
   if (!walk_subtrees)
     {
-      if (statement_code_p (code) || code == TREE_LIST
+      if (STATEMENT_CODE_P (code) || code == TREE_LIST
          || (*lang_hooks.tree_inlining.tree_chain_matters_p) (*tp))
        /* But we still need to check our siblings.  */
        WALK_SUBTREE_TAIL (TREE_CHAIN (*tp));
@@ -1613,7 +1613,7 @@ walk_tree (tp, func, data, htab_)
 #ifndef INLINER_FOR_JAVA
       /* Set lineno here so we get the right instantiation context
         if we call instantiate_decl from inlinable_function_p.  */
-      if (statement_code_p (code) && !STMT_LINENO_FOR_FN_P (*tp))
+      if (STATEMENT_CODE_P (code) && !STMT_LINENO_FOR_FN_P (*tp))
        lineno = STMT_LINENO (*tp);
 #endif /* not INLINER_FOR_JAVA */
 
@@ -1632,7 +1632,7 @@ walk_tree (tp, func, data, htab_)
 #ifndef INLINER_FOR_JAVA
       /* For statements, we also walk the chain so that we cover the
         entire statement tree.  */
-      if (statement_code_p (code))
+      if (STATEMENT_CODE_P (code))
        {
          if (code == DECL_STMT
              && DECL_STMT_DECL (*tp)
@@ -1823,7 +1823,7 @@ copy_tree_r (tp, walk_subtrees, data)
       if (code == PARM_DECL || code == TREE_LIST
 #ifndef INLINER_FOR_JAVA
          || (*lang_hooks.tree_inlining.tree_chain_matters_p) (*tp)
-         || statement_code_p (code))
+         || STATEMENT_CODE_P (code))
        TREE_CHAIN (*tp) = chain;
 
       /* For now, we don't update BLOCKs when we make copies.  So, we