error.c: Reduce code duplication.
authorGabriel Dos Reis <gdr@gcc.gnu.org>
Fri, 17 Sep 1999 01:49:29 +0000 (01:49 +0000)
committerGabriel Dos Reis <gdr@gcc.gnu.org>
Fri, 17 Sep 1999 01:49:29 +0000 (01:49 +0000)
1999-09-17  Gabriel Dos Reis  <gdr@codesourcery.com>

        * error.c: Reduce code duplication.
        (dump_template_value): New function.
        (dump_type_real): Use it.
        (dump_decl): Likewise.
        (dump_function_name): Likewise.
        (dump_function_decl): Don't be too talkative about function return
        type variety.

From-SVN: r29469

gcc/cp/ChangeLog
gcc/cp/error.c

index 3f7d508db23096c836915599e627f7c4077555ea..7f268ac98a767bb92c11e0ad113806d684142eaf 100644 (file)
@@ -1,3 +1,4 @@
+
 1999-09-16  Jason Merrill  <jason@yorick.cygnus.com>
 
        * decl.c (saved_scope_p): New fn.
index 1d1716a01a6c7b5496bbd18cce89916556d439a6..5bf5f0fbd774e943bbdaa7fe2ec3b5440e99e736 100644 (file)
@@ -116,6 +116,7 @@ static void dump_exception_spec PROTO((tree, int));
 static const char *aggr_variety PROTO((tree));
 static tree ident_fndecl PROTO((tree));
 static int interesting_scope_p PROTO((tree));
+static void dump_template_value PROTO((tree, int, int));
 
 void
 init_error ()
@@ -187,6 +188,22 @@ dump_qualifiers (t, p)
    value.  */
 static char digit_buffer[128];
 
+/* Dump a template parameter or template argument VALUE at VERBOSITY
+   level.  The boolean CANONICAL_NAME indicates whether to dump abstract
+   names, e.g. typedefs, or not. */
+
+static void
+dump_template_value (value, verbosity, canonical_name)
+     tree value;
+     int verbosity, canonical_name;
+{
+  if (TREE_CODE_CLASS (TREE_CODE (value)) == 't'
+      || TREE_CODE (value) == TEMPLATE_DECL)
+    dump_type_real (value, verbosity, canonical_name);
+  else
+    dump_expr (value, verbosity);
+}
+
 /* Dump into the obstack a human-readable equivalent of TYPE.  */
 
 static void
@@ -282,12 +299,7 @@ dump_type_real (t, v, canonical_name)
          OB_PUTC ('<');
          for (i = 0; i < TREE_VEC_LENGTH (args); i++)
            {
-             tree arg = TREE_VEC_ELT (args, i);
-             if (TREE_CODE_CLASS (TREE_CODE (arg)) == 't'
-                 || TREE_CODE (arg) == TEMPLATE_DECL)
-               dump_type_real (arg, 0, canonical_name);
-             else
-               dump_expr (arg, 0);
+              dump_template_value (TREE_VEC_ELT (args, i), 0, canonical_name);
              if (i < TREE_VEC_LENGTH (args)-1)
                OB_PUTC2 (',', ' ');
            }
@@ -895,11 +907,7 @@ dump_decl (t, v)
        OB_PUTC ('<');
        for (args = TREE_OPERAND (t, 1); args; args = TREE_CHAIN (args))
          {
-           if (TREE_CODE_CLASS (TREE_CODE (TREE_VALUE (args))) == 't'
-               || TREE_CODE (TREE_VALUE (args)) == TEMPLATE_DECL)
-             dump_type (TREE_VALUE (args), 0);
-           else
-             dump_expr (TREE_VALUE (args), 0);
+            dump_template_value (TREE_VALUE (args), 0, 0);
            if (TREE_CHAIN (args))
              OB_PUTC2 (',', ' ');
          }
@@ -985,7 +993,7 @@ dump_function_decl (t, v)
          && ! DECL_CONSTRUCTOR_P (t)
          && ! DECL_DESTRUCTOR_P (t))
        {
-         dump_type_prefix (TREE_TYPE (fntype), 1, 0);
+         dump_type_prefix (TREE_TYPE (fntype), 0, 0);
          OB_PUTC (' ');
        }
     }
@@ -1149,13 +1157,7 @@ dump_function_name (t)
                    OB_PUTS (", ");
                  
                  if (a)
-                   {
-                     if (TREE_CODE_CLASS (TREE_CODE (a)) == 't'
-                         || TREE_CODE (a) == TEMPLATE_DECL)
-                       dump_type (a, 0);
-                     else
-                       dump_expr (a, 0);
-                   }
+                    dump_template_value (a, 0, 0);
                  
                  need_comma = 1;
                }
@@ -1178,13 +1180,7 @@ dump_function_name (t)
                    OB_PUTS (", ");
                  
                  if (a)
-                   {
-                     if (TREE_CODE_CLASS (TREE_CODE (a)) == 't'
-                         || TREE_CODE (a) == TEMPLATE_DECL)
-                       dump_type (a, 0);
-                     else
-                       dump_expr (a, 0);
-                   }
+                    dump_template_value (a, 0, 0);
                  
                  need_comma = 1;
                }