OSDN Git Service

* cp-tree.h (VAR_OR_FUNCTION_DECL_CHECK,
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 28 Jun 2004 16:10:55 +0000 (16:10 +0000)
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 28 Jun 2004 16:10:55 +0000 (16:10 +0000)
        VAR_FUNCTION_OR_PARM_DECL_CHECK, RECORD_OR_UNION_TYPE_CHECK,
        BOUND_TEMPLATE_TEMPLATE_PARM_TYPE_CHECK): Use appropriate
        TREE_CHECK macro.:qOR_FUNCTION_DECL_CHECK,
        * tree.h (tree_check_failed): Make varadic.
        (tree_not_check_failed): New prototype.
        (tree_check2_failed, tree_check3_failed,
        tree_check4_failed, tree_check5_failed): Remove.
        (TREE_CHECK, TREE_CHECK2, TREE_CHECK3, TREE_CHECK4,
        TREE_CHECK5): Adjust.
        (TREE_NOT_CHECK, TREE_NOT_CHECK2, TREE_NOT_CHECK3, TREE_NOT_CHECK4,
        TREE_NOT_CHECK5): New.
        (TREE_VEC_ELT_CHECK, PHI_NODE_ELT_CHECK, TREE_OPERAND_CHECK_CODE,
        TREE_RTL_OPERAND_CHECK): Adjust.
        * tree.c (tree_check_failed): Make varadic.
        (tree_not_check_failed): New.
        (tree_check2_failed, tree_check3_failed,
        tree_check4_failed, tree_check5_failed): Remove.
cp:
        * cp-tree.h (VAR_OR_FUNCTION_DECL_CHECK,
        VAR_FUNCTION_OR_PARM_DECL_CHECK, RECORD_OR_UNION_TYPE_CHECK,
        BOUND_TEMPLATE_TEMPLATE_PARM_TYPE_CHECK): Use appropriate
        TREE_CHECK macro.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@83796 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/tree.c
gcc/tree.h

index fa3ddd5..2058e15 100644 (file)
@@ -1,3 +1,20 @@
+2004-06-28  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * tree.h (tree_check_failed): Make varadic.
+       (tree_not_check_failed): New prototype.
+       (tree_check2_failed, tree_check3_failed,
+       tree_check4_failed, tree_check5_failed): Remove.
+       (TREE_CHECK, TREE_CHECK2, TREE_CHECK3, TREE_CHECK4,
+       TREE_CHECK5): Adjust.
+       (TREE_NOT_CHECK, TREE_NOT_CHECK2, TREE_NOT_CHECK3, TREE_NOT_CHECK4, 
+       TREE_NOT_CHECK5): New.
+       (TREE_VEC_ELT_CHECK, PHI_NODE_ELT_CHECK, TREE_OPERAND_CHECK_CODE,
+       TREE_RTL_OPERAND_CHECK): Adjust.
+       * tree.c (tree_check_failed): Make varadic.
+       (tree_not_check_failed): New.
+       (tree_check2_failed, tree_check3_failed,
+       tree_check4_failed, tree_check5_failed): Remove.
+
 2004-06-28  Ulrich Weigand  <uweigand@de.ibm.com>
 
        * combine.c (can_combine_p): Do not prevent building insns that use
index 6601907..ad782f2 100644 (file)
@@ -1,5 +1,12 @@
 2004-06-28  Nathan Sidwell  <nathan@codesourcery.com>
 
+       * cp-tree.h (VAR_OR_FUNCTION_DECL_CHECK,
+       VAR_FUNCTION_OR_PARM_DECL_CHECK, RECORD_OR_UNION_TYPE_CHECK,
+       BOUND_TEMPLATE_TEMPLATE_PARM_TYPE_CHECK): Use appropriate
+       TREE_CHECK macro.
+
+2004-06-28  Nathan Sidwell  <nathan@codesourcery.com>
+
        * cp-tree.h (struct deferred_access): Move to ...
        * semantics.c (struct deferred_access): ... here. Adjust.
        (deferred_access_stack): Make a VEC(deferred_access),
index 71f4f9a..8dfe109 100644 (file)
@@ -160,62 +160,20 @@ struct diagnostic_context;
 
 /* Language-specific tree checkers.  */
 
-#if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
+#define VAR_OR_FUNCTION_DECL_CHECK(NODE) \
+  TREE_CHECK2(NODE,VAR_DECL,FUNCTION_DECL)
 
-#define VAR_OR_FUNCTION_DECL_CHECK(NODE) __extension__         \
-({  const tree __t = (NODE);                                   \
-    enum tree_code const __c = TREE_CODE(__t);                 \
-    if (__c != VAR_DECL && __c != FUNCTION_DECL)               \
-      tree_check_failed (__t, VAR_DECL, __FILE__, __LINE__,    \
-                        __FUNCTION__);                         \
-    __t; })
-
-#define VAR_FUNCTION_OR_PARM_DECL_CHECK(NODE) __extension__    \
-({  const tree __t = (NODE);                                   \
-    enum tree_code const __c = TREE_CODE(__t);                 \
-    if (__c != VAR_DECL                                                \
-       && __c != FUNCTION_DECL                                 \
-        && __c != PARM_DECL)                                   \
-      tree_check_failed (__t, VAR_DECL, __FILE__, __LINE__,    \
-                        __FUNCTION__);                         \
-    __t; })
-
-#define VAR_TEMPL_TYPE_OR_FUNCTION_DECL_CHECK(NODE) __extension__ \
-({  const tree __t = (NODE);                                   \
-    enum tree_code const __c = TREE_CODE(__t);                 \
-    if (__c != VAR_DECL                                                \
-       && __c != FUNCTION_DECL                                 \
-       && __c != TYPE_DECL                                     \
-       && __c != TEMPLATE_DECL)                                \
-      tree_check_failed (__t, VAR_DECL, __FILE__, __LINE__,    \
-                        __FUNCTION__);                         \
-    __t; })
-
-#define RECORD_OR_UNION_TYPE_CHECK(NODE) __extension__         \
-({  const tree __t = (NODE);                                   \
-    enum tree_code const __c = TREE_CODE(__t);                 \
-    if (__c != RECORD_TYPE && __c != UNION_TYPE)               \
-      tree_check_failed (__t, RECORD_TYPE, __FILE__, __LINE__, \
-                        __FUNCTION__);                         \
-    __t; })
-
-#define BOUND_TEMPLATE_TEMPLATE_PARM_TYPE_CHECK(NODE) __extension__ \
-({  const tree __t = (NODE);                                   \
-    enum tree_code const __c = TREE_CODE(__t);                 \
-    if (__c != BOUND_TEMPLATE_TEMPLATE_PARM)                   \
-      tree_check_failed (__t, BOUND_TEMPLATE_TEMPLATE_PARM,    \
-                        __FILE__, __LINE__, __FUNCTION__);     \
-    __t; })
-
-#else /* not ENABLE_TREE_CHECKING, or not gcc */
-
-#define VAR_OR_FUNCTION_DECL_CHECK(NODE)               (NODE)
-#define VAR_FUNCTION_OR_PARM_DECL_CHECK(NODE)          (NODE)
-#define VAR_TEMPL_TYPE_OR_FUNCTION_DECL_CHECK(NODE)    (NODE)
-#define RECORD_OR_UNION_TYPE_CHECK(NODE)               (NODE)
-#define BOUND_TEMPLATE_TEMPLATE_PARM_TYPE_CHECK(NODE)  (NODE)
+#define VAR_FUNCTION_OR_PARM_DECL_CHECK(NODE) \
+  TREE_CHECK3(NODE,VAR_DECL,FUNCTION_DECL,PARM_DECL)
 
-#endif
+#define VAR_TEMPL_TYPE_OR_FUNCTION_DECL_CHECK(NODE) \
+  TREE_CHECK4(NODE,VAR_DECL,FUNCTION_DECL,TYPE_DECL,TEMPLATE_DECL)
+
+#define RECORD_OR_UNION_TYPE_CHECK(NODE) \
+  TREE_CHECK2(NODE,RECORD_TYPE,UNION_TYPE)
+
+#define BOUND_TEMPLATE_TEMPLATE_PARM_TYPE_CHECK(NODE) \
+  TREE_CHECK(NODE,BOUND_TEMPLATE_TEMPLATE_PARM)
 
 \f
 /* Language-dependent contents of an identifier.  */
index e0a1c46..ba95e15 100644 (file)
@@ -5108,75 +5108,80 @@ get_set_constructor_bytes (tree init, unsigned char *buffer, int wd_size)
 \f
 #if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007)
 
-/* Complain that the tree code of NODE does not match the expected CODE.
-   FILE, LINE, and FUNCTION are of the caller.  */
+/* Complain that the tree code of NODE does not match the expected 0
+   terminated list of trailing codes. FILE, LINE, and FUNCTION are of
+   the caller.  */
 
 void
-tree_check_failed (const tree node, enum tree_code code, const char *file,
-                  int line, const char *function)
-{
+tree_check_failed (const tree node, const char *file,
+                  int line, const char *function, ...)
+{
+  va_list args;
+  char *buffer;
+  unsigned length = 0;
+  int code;
+
+  va_start (args, function);
+  while ((code = va_arg (args, int)))
+    length += 4 + strlen (tree_code_name[code]);
+  va_end (args);
+  va_start (args, function);
+  buffer = alloca (length);
+  length = 0;
+  while ((code = va_arg (args, int)))
+    {
+      if (length)
+       {
+         strcpy (buffer + length, " or ");
+         length += 4;
+       }
+      strcpy (buffer + length, tree_code_name[code]);
+      length += strlen (tree_code_name[code]);
+    }
+  va_end (args);
+  
   internal_error ("tree check: expected %s, have %s in %s, at %s:%d",
-                 tree_code_name[code], tree_code_name[TREE_CODE (node)],
-                 function, trim_filename (file), line);
-}
-
-/* Similar to above except that we allowed the code to be one of two
-   different codes.  */
-
-void
-tree_check2_failed (const tree node, enum tree_code code1,
-                   enum tree_code code2, const char *file,
-                   int line, const char *function)
-{
-  internal_error ("tree check: expected %s or %s, have %s in %s, at %s:%d",
-                 tree_code_name[code1], tree_code_name[code2],
-                 tree_code_name[TREE_CODE (node)],
+                 buffer, tree_code_name[TREE_CODE (node)],
                  function, trim_filename (file), line);
 }
 
-/* Likewise for three different codes.  */
+/* Complain that the tree code of NODE does match the expected 0
+   terminated list of trailing codes. FILE, LINE, and FUNCTION are of
+   the caller.  */
 
 void
-tree_check3_failed (const tree node, enum tree_code code1,
-                   enum tree_code code2, enum tree_code code3,
-                   const char *file, int line, const char *function)
-{
-  internal_error ("tree check: expected %s, %s or %s; have %s in %s, at %s:%d",
-                 tree_code_name[code1], tree_code_name[code2],
-                 tree_code_name[code3], tree_code_name[TREE_CODE (node)],
+tree_not_check_failed (const tree node, const char *file,
+                      int line, const char *function, ...)
+{
+  va_list args;
+  char *buffer;
+  unsigned length = 0;
+  int code;
+
+  va_start (args, function);
+  while ((code = va_arg (args, int)))
+    length += 4 + strlen (tree_code_name[code]);
+  va_end (args);
+  va_start (args, function);
+  buffer = alloca (length);
+  length = 0;
+  while ((code = va_arg (args, int)))
+    {
+      if (length)
+       {
+         strcpy (buffer + length, " or ");
+         length += 4;
+       }
+      strcpy (buffer + length, tree_code_name[code]);
+      length += strlen (tree_code_name[code]);
+    }
+  va_end (args);
+  
+  internal_error ("tree check: expected none of %s, have %s in %s, at %s:%d",
+                 buffer, tree_code_name[TREE_CODE (node)],
                  function, trim_filename (file), line);
 }
 
-/* ... and for four different codes.  */
-
-void
-tree_check4_failed (const tree node, enum tree_code code1,
-                   enum tree_code code2, enum tree_code code3,
-                   enum tree_code code4, const char *file, int line,
-                   const char *function)
-{
-  internal_error
-    ("tree check: expected %s, %s, %s or %s; have %s in %s, at %s:%d",
-     tree_code_name[code1], tree_code_name[code2], tree_code_name[code3],
-     tree_code_name[code4], tree_code_name[TREE_CODE (node)], function,
-     trim_filename (file), line);
-}
-
-/* ... and for five different codes.  */
-
-void
-tree_check5_failed (const tree node, enum tree_code code1,
-                   enum tree_code code2, enum tree_code code3,
-                   enum tree_code code4, enum tree_code code5,
-                   const char *file, int line, const char *function)
-{
-  internal_error
-    ("tree check: expected %s, %s, %s, %s or %s; have %s in %s, at %s:%d",
-     tree_code_name[code1], tree_code_name[code2], tree_code_name[code3],
-     tree_code_name[code4], tree_code_name[code5],
-     tree_code_name[TREE_CODE (node)], function, trim_filename (file), line);
-}
-
 /* Similar to tree_check_failed, except that we check for a class of tree
    code, given in CL.  */
 
index 57d1970..a9a450d 100644 (file)
@@ -342,15 +342,31 @@ struct tree_common GTY(())
 #define TREE_CHECK(T, CODE) __extension__                              \
 ({  const tree __t = (T);                                              \
     if (TREE_CODE (__t) != (CODE))                                     \
-      tree_check_failed (__t, (CODE), __FILE__, __LINE__, __FUNCTION__); \
+      tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__,        \
+                        (CODE), 0);                                    \
+    __t; })
+
+#define TREE_NOT_CHECK(T, CODE) __extension__                          \
+({  const tree __t = (T);                                              \
+    if (TREE_CODE (__t) == (CODE))                                     \
+      tree_not_check_failed (__t, __FILE__, __LINE__, __FUNCTION__,    \
+                            (CODE), 0);                                \
     __t; })
 
 #define TREE_CHECK2(T, CODE1, CODE2) __extension__                     \
 ({  const tree __t = (T);                                              \
     if (TREE_CODE (__t) != (CODE1)                                     \
        && TREE_CODE (__t) != (CODE2))                                  \
-      tree_check2_failed (__t, (CODE1), (CODE2), __FILE__, __LINE__,   \
-                         __FUNCTION__);                                \
+      tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__,                \
+                        (CODE1), (CODE2), 0);                          \
+    __t; })
+
+#define TREE_NOT_CHECK2(T, CODE1, CODE2) __extension__                 \
+({  const tree __t = (T);                                              \
+    if (TREE_CODE (__t) == (CODE1)                                     \
+       || TREE_CODE (__t) == (CODE2))                                  \
+      tree_not_check_failed (__t, __FILE__, __LINE__, __FUNCTION__,    \
+                            (CODE1), (CODE2), 0);                      \
     __t; })
 
 #define TREE_CHECK3(T, CODE1, CODE2, CODE3) __extension__              \
@@ -358,8 +374,17 @@ struct tree_common GTY(())
     if (TREE_CODE (__t) != (CODE1)                                     \
        && TREE_CODE (__t) != (CODE2)                                   \
        && TREE_CODE (__t) != (CODE3))                                  \
-      tree_check3_failed (__t, (CODE1), (CODE2), (CODE3), __FILE__,    \
-                         __LINE__, __FUNCTION__);                      \
+      tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__,                \
+                            (CODE1), (CODE2), (CODE3), 0);             \
+    __t; })
+
+#define TREE_NOT_CHECK3(T, CODE1, CODE2, CODE3) __extension__          \
+({  const tree __t = (T);                                              \
+    if (TREE_CODE (__t) == (CODE1)                                     \
+       || TREE_CODE (__t) == (CODE2)                                   \
+       || TREE_CODE (__t) == (CODE3))                                  \
+      tree_not_check_failed (__t, __FILE__, __LINE__, __FUNCTION__,    \
+                            (CODE1), (CODE2), (CODE3), 0);             \
     __t; })
 
 #define TREE_CHECK4(T, CODE1, CODE2, CODE3, CODE4) __extension__       \
@@ -368,8 +393,18 @@ struct tree_common GTY(())
        && TREE_CODE (__t) != (CODE2)                                   \
        && TREE_CODE (__t) != (CODE3)                                   \
        && TREE_CODE (__t) != (CODE4))                                  \
-      tree_check4_failed (__t, (CODE1), (CODE2), (CODE3), (CODE4),     \
-                          __FILE__, __LINE__, __FUNCTION__);           \
+      tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__,                \
+                            (CODE1), (CODE2), (CODE3), (CODE4), 0);    \
+    __t; })
+
+#define NON_TREE_CHECK4(T, CODE1, CODE2, CODE3, CODE4) __extension__   \
+({  const tree __t = (T);                                              \
+    if (TREE_CODE (__t) == (CODE1)                                     \
+       || TREE_CODE (__t) == (CODE2)                                   \
+       || TREE_CODE (__t) == (CODE3)                                   \
+       || TREE_CODE (__t) == (CODE4))                                  \
+      tree_not_check_failed (__t, __FILE__, __LINE__, __FUNCTION__,    \
+                            (CODE1), (CODE2), (CODE3), (CODE4), 0);    \
     __t; })
 
 #define TREE_CHECK5(T, CODE1, CODE2, CODE3, CODE4, CODE5) __extension__        \
@@ -379,8 +414,19 @@ struct tree_common GTY(())
        && TREE_CODE (__t) != (CODE3)                                   \
        && TREE_CODE (__t) != (CODE4)                                   \
        && TREE_CODE (__t) != (CODE5))                                  \
-      tree_check5_failed (__t, (CODE1), (CODE2), (CODE3), (CODE4),     \
-                         (CODE5), __FILE__, __LINE__, __FUNCTION__);   \
+      tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__,                \
+                            (CODE1), (CODE2), (CODE3), (CODE4), (CODE5), 0);\
+    __t; })
+
+#define TREE_NOT_CHECK5(T, CODE1, CODE2, CODE3, CODE4, CODE5) __extension__ \
+({  const tree __t = (T);                                              \
+    if (TREE_CODE (__t) == (CODE1)                                     \
+       || TREE_CODE (__t) == (CODE2)                                   \
+       || TREE_CODE (__t) == (CODE3)                                   \
+       || TREE_CODE (__t) == (CODE4)                                   \
+       || TREE_CODE (__t) == (CODE5))                                  \
+      tree_not_check_failed (__t, __FILE__, __LINE__, __FUNCTION__,    \
+                            (CODE1), (CODE2), (CODE3), (CODE4), (CODE5), 0);\
     __t; })
 
 #define TREE_CLASS_CHECK(T, CLASS) __extension__                       \
@@ -412,8 +458,8 @@ struct tree_common GTY(())
 (*({const tree __t = (T);                                              \
     const int __i = (I);                                               \
     if (TREE_CODE (__t) != TREE_VEC)                                   \
-      tree_check_failed (__t, TREE_VEC,                                        \
-                        __FILE__, __LINE__, __FUNCTION__);             \
+      tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__,                \
+                        TREE_VEC, 0);                                  \
     if (__i < 0 || __i >= __t->vec.length)                             \
       tree_vec_elt_check_failed (__i, __t->vec.length,                 \
                                 __FILE__, __LINE__, __FUNCTION__);     \
@@ -423,8 +469,8 @@ struct tree_common GTY(())
 (*({const tree __t = t;                                                        \
     const int __i = (i);                                               \
     if (TREE_CODE (__t) != PHI_NODE)                                   \
-      tree_check_failed (__t, PHI_NODE,                                        \
-                        __FILE__, __LINE__, __FUNCTION__);             \
+      tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__,        \
+                        PHI_NODE, 0);                                  \
     if (__i < 0 || __i >= __t->phi.capacity)                           \
       phi_node_elt_check_failed (__i, __t->phi.num_args,               \
                                 __FILE__, __LINE__, __FUNCTION__);     \
@@ -443,7 +489,7 @@ struct tree_common GTY(())
 (*({const tree __t = (T);                                              \
     const int __i = (I);                                               \
     if (TREE_CODE (__t) != CODE)                                       \
-      tree_check_failed (__t, CODE, __FILE__, __LINE__, __FUNCTION__); \
+      tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, (CODE), 0);\
     if (__i < 0 || __i >= TREE_CODE_LENGTH (CODE))                     \
       tree_operand_check_failed (__i, (CODE),                          \
                                 __FILE__, __LINE__, __FUNCTION__);     \
@@ -454,30 +500,16 @@ struct tree_common GTY(())
  ({const tree __t = (T);                                               \
     const int __i = (I);                                               \
     if (TREE_CODE (__t) != (CODE))                                     \
-      tree_check_failed (__t, (CODE), __FILE__, __LINE__, __FUNCTION__); \
+      tree_check_failed (__t, __FILE__, __LINE__, __FUNCTION__, (CODE), 0); \
     if (__i < 0 || __i >= TREE_CODE_LENGTH ((CODE)))                   \
       tree_operand_check_failed (__i, (CODE),                          \
                                 __FILE__, __LINE__, __FUNCTION__);     \
     &__t->exp.operands[__i]; }))
 
-extern void tree_check_failed (const tree, enum tree_code,
-                              const char *, int, const char *)
-    ATTRIBUTE_NORETURN;
-extern void tree_check2_failed (const tree, enum tree_code, enum tree_code,
-                              const char *, int, const char *)
-    ATTRIBUTE_NORETURN;
-extern void tree_check3_failed (const tree, enum tree_code, enum tree_code,
-                               enum tree_code, const char *, int,
-                               const char *)
-    ATTRIBUTE_NORETURN;
-extern void tree_check4_failed (const tree, enum tree_code, enum tree_code,
-                               enum tree_code, enum tree_code,
-                               const char *, int, const char *)
-    ATTRIBUTE_NORETURN;
-extern void tree_check5_failed (const tree, enum tree_code, enum tree_code,
-                               enum tree_code, enum tree_code, enum tree_code,
-                               const char *, int, const char *)
-    ATTRIBUTE_NORETURN;
+extern void tree_check_failed (const tree, const char *, int, const char *,
+                              ...) ATTRIBUTE_NORETURN;
+extern void tree_not_check_failed (const tree, const char *, int, const char *,
+                                  ...) ATTRIBUTE_NORETURN;
 extern void tree_class_check_failed (const tree, int,
                                     const char *, int, const char *)
     ATTRIBUTE_NORETURN;
@@ -494,10 +526,15 @@ extern void tree_operand_check_failed (int, enum tree_code,
 #else /* not ENABLE_TREE_CHECKING, or not gcc */
 
 #define TREE_CHECK(T, CODE)                    (T)
+#define TREE_NOT_CHECK(T, CODE)                        (T)
 #define TREE_CHECK2(T, CODE1, CODE2)           (T)
+#define TREE_NOT_CHECK2(T, CODE1, CODE2)       (T)
 #define TREE_CHECK3(T, CODE1, CODE2, CODE3)    (T)
+#define TREE_NOT_CHECK3(T, CODE1, CODE2, CODE3)        (T)
 #define TREE_CHECK4(T, CODE1, CODE2, CODE3, CODE4) (T)
+#define TREE_NOT_CHECK4(T, CODE1, CODE2, CODE3, CODE4) (T)
 #define TREE_CHECK5(T, CODE1, CODE2, CODE3, CODE4, CODE5) (T)
+#define TREE_NOT_CHECK5(T, CODE1, CODE2, CODE3, CODE4, CODE5) (T)
 #define TREE_CLASS_CHECK(T, CODE)              (T)
 #define EXPR_CHECK(T)                          (T)
 #define NON_TYPE_CHECK(T)                      (T)