OSDN Git Service

cp:
[pf3gnuchains/gcc-fork.git] / gcc / cp / error.c
index 9f79a26..3d202d6 100644 (file)
@@ -1,7 +1,7 @@
 /* Call-backs for C++ error reporting.
    This code is non-reentrant.
    Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002,
-   2003, 2004 Free Software Foundation, Inc.
+   2003, 2004, 2005 Free Software Foundation, Inc.
    This file is part of GCC.
 
 GCC is free software; you can redistribute it and/or modify
@@ -70,7 +70,6 @@ static void dump_expr_list (tree, int);
 static void dump_global_iord (tree);
 static void dump_parameters (tree, int);
 static void dump_exception_spec (tree, int);
-static const char *class_key_or_enum (tree);
 static void dump_template_argument (tree, int);
 static void dump_template_argument_list (tree, int);
 static void dump_template_parameter (tree, int);
@@ -82,7 +81,7 @@ static const char *function_category (tree);
 static void maybe_print_instantiation_context (diagnostic_context *);
 static void print_instantiation_full_context (diagnostic_context *);
 static void print_instantiation_partial_context (diagnostic_context *,
-                                                 tree, location_t);
+                                                tree, location_t);
 static void cp_diagnostic_starter (diagnostic_context *, diagnostic_info *);
 static void cp_diagnostic_finalizer (diagnostic_context *, diagnostic_info *);
 static void cp_print_error_function (diagnostic_context *, diagnostic_info *);
@@ -115,10 +114,10 @@ dump_scope (tree scope, int flags)
   if (TREE_CODE (scope) == NAMESPACE_DECL)
     {
       if (scope != global_namespace)
-        {
-          dump_decl (scope, f);
-          pp_cxx_colon_colon (cxx_pp);
-        }
+       {
+         dump_decl (scope, f);
+         pp_cxx_colon_colon (cxx_pp);
+       }
     }
   else if (AGGREGATE_TYPE_P (scope))
     {
@@ -156,7 +155,7 @@ dump_template_argument_list (tree args, int flags)
   for (i = 0; i< n; ++i)
     {
       if (need_comma)
-        pp_separate_with_comma (cxx_pp);
+       pp_separate_with_comma (cxx_pp);
       dump_template_argument (TREE_VEC_ELT (args, i), flags);
       need_comma = 1;
     }
@@ -173,15 +172,15 @@ dump_template_parameter (tree parm, int flags)
   if (TREE_CODE (p) == TYPE_DECL)
     {
       if (flags & TFF_DECL_SPECIFIERS)
-        {
-          pp_cxx_identifier (cxx_pp, "class");
-          if (DECL_NAME (p))
-            pp_cxx_tree_identifier (cxx_pp, DECL_NAME (p));
-        }
+       {
+         pp_cxx_identifier (cxx_pp, "class");
+         if (DECL_NAME (p))
+           pp_cxx_tree_identifier (cxx_pp, DECL_NAME (p));
+       }
       else if (DECL_NAME (p))
-        pp_cxx_tree_identifier (cxx_pp, DECL_NAME (p));
+       pp_cxx_tree_identifier (cxx_pp, DECL_NAME (p));
       else
-        pp_cxx_canonical_template_parameter (cxx_pp, TREE_TYPE (p));
+       pp_cxx_canonical_template_parameter (cxx_pp, TREE_TYPE (p));
     }
   else
     dump_decl (p, flags | TFF_DECL_SPECIFIERS);
@@ -192,9 +191,9 @@ dump_template_parameter (tree parm, int flags)
       pp_equal (cxx_pp);
       pp_cxx_whitespace (cxx_pp);
       if (TREE_CODE (p) == TYPE_DECL || TREE_CODE (p) == TEMPLATE_DECL)
-        dump_type (a, flags & ~TFF_CHASE_TYPEDEF);
+       dump_type (a, flags & ~TFF_CHASE_TYPEDEF);
       else
-        dump_expr (a, flags | TFF_EXPR_IN_PARENS);
+       dump_expr (a, flags | TFF_EXPR_IN_PARENS);
     }
 }
 
@@ -229,9 +228,9 @@ dump_template_bindings (tree parms, tree args)
          if (need_comma)
            pp_separate_with_comma (cxx_pp);
          dump_template_parameter (TREE_VEC_ELT (p, i), TFF_PLAIN_IDENTIFIER);
-          pp_cxx_whitespace (cxx_pp);
-          pp_equal (cxx_pp);
-          pp_cxx_whitespace (cxx_pp);
+         pp_cxx_whitespace (cxx_pp);
+         pp_equal (cxx_pp);
+         pp_cxx_whitespace (cxx_pp);
          if (arg)
            dump_template_argument (arg, TFF_PLAIN_IDENTIFIER);
          else
@@ -284,11 +283,11 @@ dump_type (tree t, int flags)
 
     case TYPE_DECL:
       if (flags & TFF_CHASE_TYPEDEF)
-        {
-          dump_type (DECL_ORIGINAL_TYPE (t)
-                     ? DECL_ORIGINAL_TYPE (t) : TREE_TYPE (t), flags);
-          break;
-        }
+       {
+         dump_type (DECL_ORIGINAL_TYPE (t)
+                    ? DECL_ORIGINAL_TYPE (t) : TREE_TYPE (t), flags);
+         break;
+       }
       /* Else fall through.  */
 
     case TEMPLATE_DECL:
@@ -310,7 +309,7 @@ dump_type (tree t, int flags)
       if (TYPE_IDENTIFIER (t))
        pp_cxx_tree_identifier (cxx_pp, TYPE_IDENTIFIER (t));
       else
-        pp_cxx_canonical_template_parameter (cxx_pp, t);
+       pp_cxx_canonical_template_parameter (cxx_pp, t);
       break;
 
     case BOUND_TEMPLATE_TEMPLATE_PARM:
@@ -319,7 +318,7 @@ dump_type (tree t, int flags)
        pp_cxx_cv_qualifier_seq (cxx_pp, t);
        pp_cxx_tree_identifier (cxx_pp, TYPE_IDENTIFIER (t));
        pp_cxx_begin_template_argument_list (cxx_pp);
-        dump_template_argument_list (args, flags);
+       dump_template_argument_list (args, flags);
        pp_cxx_end_template_argument_list (cxx_pp);
       }
       break;
@@ -329,8 +328,8 @@ dump_type (tree t, int flags)
       if (TYPE_IDENTIFIER (t))
        pp_cxx_tree_identifier (cxx_pp, TYPE_IDENTIFIER (t));
       else
-        pp_cxx_canonical_template_parameter
-          (cxx_pp, TEMPLATE_TYPE_PARM_INDEX (t));
+       pp_cxx_canonical_template_parameter
+         (cxx_pp, TEMPLATE_TYPE_PARM_INDEX (t));
       break;
 
       /* This is not always necessary for pointers and such, but doing this
@@ -349,7 +348,10 @@ dump_type (tree t, int flags)
     }
     case TYPENAME_TYPE:
       pp_cxx_cv_qualifier_seq (cxx_pp, t);
-      pp_cxx_identifier (cxx_pp, "typename");
+      pp_cxx_identifier (cxx_pp,
+                        TYPENAME_IS_ENUM_P (t) ? "enum"
+                        : TYPENAME_IS_CLASS_P (t) ? "class"
+                        : "typename");
       dump_typename (t, flags);
       break;
 
@@ -396,8 +398,8 @@ dump_typename (tree t, int flags)
 
 /* Return the name of the supplied aggregate, or enumeral type.  */
 
-static const char *
-class_key_or_enum (tree t)
+const char *
+class_key_or_enum_as_string (tree t)
 {
   if (TREE_CODE (t) == ENUMERAL_TYPE)
     return "enum";
@@ -416,7 +418,7 @@ static void
 dump_aggr_type (tree t, int flags)
 {
   tree name;
-  const char *variety = class_key_or_enum (t);
+  const char *variety = class_key_or_enum_as_string (t);
   int typdef = 0;
   int tmplate = 0;
 
@@ -434,38 +436,38 @@ dump_aggr_type (tree t, int flags)
     {
       typdef = !DECL_ARTIFICIAL (name);
       tmplate = !typdef && TREE_CODE (t) != ENUMERAL_TYPE
-                && TYPE_LANG_SPECIFIC (t) && CLASSTYPE_TEMPLATE_INFO (t)
-                && (CLASSTYPE_TEMPLATE_SPECIALIZATION (t)
-                    || TREE_CODE (CLASSTYPE_TI_TEMPLATE (t)) != TEMPLATE_DECL
-                    || DECL_TEMPLATE_SPECIALIZATION (CLASSTYPE_TI_TEMPLATE (t))
-                    || PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (t)));
+               && TYPE_LANG_SPECIFIC (t) && CLASSTYPE_TEMPLATE_INFO (t)
+               && (CLASSTYPE_TEMPLATE_SPECIALIZATION (t)
+                   || TREE_CODE (CLASSTYPE_TI_TEMPLATE (t)) != TEMPLATE_DECL
+                   || DECL_TEMPLATE_SPECIALIZATION (CLASSTYPE_TI_TEMPLATE (t))
+                   || PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (t)));
       dump_scope (CP_DECL_CONTEXT (name), flags | TFF_SCOPE);
       if (tmplate)
-        {
-          /* Because the template names are mangled, we have to locate
-             the most general template, and use that name.  */
-          tree tpl = CLASSTYPE_TI_TEMPLATE (t);
-
-          while (DECL_TEMPLATE_INFO (tpl))
-            tpl = DECL_TI_TEMPLATE (tpl);
-          name = tpl;
-        }
+       {
+         /* Because the template names are mangled, we have to locate
+            the most general template, and use that name.  */
+         tree tpl = CLASSTYPE_TI_TEMPLATE (t);
+
+         while (DECL_TEMPLATE_INFO (tpl))
+           tpl = DECL_TI_TEMPLATE (tpl);
+         name = tpl;
+       }
       name = DECL_NAME (name);
     }
 
   if (name == 0 || ANON_AGGRNAME_P (name))
     {
       if (flags & TFF_CLASS_KEY_OR_ENUM)
-        pp_identifier (cxx_pp, "<anonymous>");
+       pp_identifier (cxx_pp, "<anonymous>");
       else
-        pp_printf (pp_base (cxx_pp), "<anonymous %s>", variety);
+       pp_printf (pp_base (cxx_pp), "<anonymous %s>", variety);
     }
   else
     pp_cxx_tree_identifier (cxx_pp, name);
   if (tmplate)
     dump_template_parms (TYPE_TEMPLATE_INFO (t),
-                         !CLASSTYPE_USE_TEMPLATE (t),
-                         flags & ~TFF_TEMPLATE_HEADER);
+                        !CLASSTYPE_USE_TEMPLATE (t),
+                        flags & ~TFF_TEMPLATE_HEADER);
 }
 
 /* Dump into the obstack the initial part of the output for a given type.
@@ -479,7 +481,7 @@ dump_aggr_type (tree t, int flags)
    Arrays must also do this for DECL nodes, like int a[], and for things like
    int *[]&.  */
 
-static void 
+static void
 dump_type_prefix (tree t, int flags)
 {
   if (TYPE_PTRMEMFUNC_P (t))
@@ -502,8 +504,8 @@ dump_type_prefix (tree t, int flags)
            pp_cxx_left_paren (cxx_pp);
          }
        pp_character (cxx_pp, "&*"[TREE_CODE (t) == POINTER_TYPE]);
-        pp_base (cxx_pp)->padding = pp_before;
-        pp_cxx_cv_qualifier_seq (cxx_pp, t);
+       pp_base (cxx_pp)->padding = pp_before;
+       pp_cxx_cv_qualifier_seq (cxx_pp, t);
       }
       break;
 
@@ -512,9 +514,9 @@ dump_type_prefix (tree t, int flags)
       dump_type_prefix (TREE_TYPE (t), flags);
       if (TREE_CODE (t) == OFFSET_TYPE)        /* pmfs deal with this in d_t_p */
        {
-          pp_maybe_space (cxx_pp);
-          if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
-             pp_cxx_left_paren (cxx_pp);
+         pp_maybe_space (cxx_pp);
+         if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
+            pp_cxx_left_paren (cxx_pp);
          dump_type (TYPE_OFFSET_BASETYPE (t), flags);
          pp_cxx_colon_colon (cxx_pp);
        }
@@ -524,7 +526,7 @@ dump_type_prefix (tree t, int flags)
       break;
 
       /* Can only be reached through function pointer -- this would not be
-         correct if FUNCTION_DECLs used it.  */
+        correct if FUNCTION_DECLs used it.  */
     case FUNCTION_TYPE:
       dump_type_prefix (TREE_TYPE (t), flags);
       pp_maybe_space (cxx_pp);
@@ -599,7 +601,7 @@ dump_type_suffix (tree t, int flags)
     case METHOD_TYPE:
       {
        tree arg;
-        pp_cxx_right_paren (cxx_pp);
+       pp_cxx_right_paren (cxx_pp);
        arg = TYPE_ARG_TYPES (t);
        if (TREE_CODE (t) == METHOD_TYPE)
          arg = TREE_CHAIN (arg);
@@ -609,8 +611,10 @@ dump_type_suffix (tree t, int flags)
        dump_parameters (arg, flags & ~TFF_FUNCTION_DEFAULT_ARGUMENTS);
 
        if (TREE_CODE (t) == METHOD_TYPE)
-          pp_cxx_cv_qualifier_seq
-            (cxx_pp, TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (t))));
+         pp_cxx_cv_qualifier_seq
+           (cxx_pp, TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (t))));
+       else
+         pp_cxx_cv_qualifier_seq(cxx_pp, t);
        dump_exception_spec (TYPE_RAISES_EXCEPTIONS (t), flags);
        dump_type_suffix (TREE_TYPE (t), flags);
        break;
@@ -623,15 +627,15 @@ dump_type_suffix (tree t, int flags)
        {
          if (host_integerp (TYPE_MAX_VALUE (TYPE_DOMAIN (t)), 0))
            pp_wide_integer
-              (cxx_pp, tree_low_cst (TYPE_MAX_VALUE (TYPE_DOMAIN (t)), 0) + 1);
+             (cxx_pp, tree_low_cst (TYPE_MAX_VALUE (TYPE_DOMAIN (t)), 0) + 1);
          else if (TREE_CODE (TYPE_MAX_VALUE (TYPE_DOMAIN (t))) == MINUS_EXPR)
            dump_expr (TREE_OPERAND (TYPE_MAX_VALUE (TYPE_DOMAIN (t)), 0),
-                      flags & ~TFF_EXPR_IN_PARENS);
+                      flags & ~TFF_EXPR_IN_PARENS);
          else
            dump_expr (fold (cp_build_binary_op
                             (PLUS_EXPR, TYPE_MAX_VALUE (TYPE_DOMAIN (t)),
                              integer_one_node)),
-                      flags & ~TFF_EXPR_IN_PARENS);
+                      flags & ~TFF_EXPR_IN_PARENS);
        }
       pp_cxx_right_bracket (cxx_pp);
       dump_type_suffix (TREE_TYPE (t), flags);
@@ -662,7 +666,7 @@ dump_type_suffix (tree t, int flags)
       pp_unsupported_tree (cxx_pp, t);
     case ERROR_MARK:
       /* Don't mark it here, we should have already done in
-         dump_type_prefix.  */
+        dump_type_prefix.  */
       break;
     }
 }
@@ -711,24 +715,22 @@ dump_decl (tree t, int flags)
   switch (TREE_CODE (t))
     {
     case TYPE_DECL:
-      {
-       /* Don't say 'typedef class A' */
-        if (DECL_ARTIFICIAL (t))
-         {
-           if ((flags & TFF_DECL_SPECIFIERS)
-               && TREE_CODE (TREE_TYPE (t)) == TEMPLATE_TYPE_PARM)
-             /* Say `class T' not just `T'.  */
-             pp_cxx_identifier (cxx_pp, "class");
+      /* Don't say 'typedef class A' */
+      if (DECL_ARTIFICIAL (t))
+       {
+         if ((flags & TFF_DECL_SPECIFIERS)
+             && TREE_CODE (TREE_TYPE (t)) == TEMPLATE_TYPE_PARM)
+           /* Say `class T' not just `T'.  */
+           pp_cxx_identifier (cxx_pp, "class");
 
-           dump_type (TREE_TYPE (t), flags);
-           break;
-         }
-      }
+         dump_type (TREE_TYPE (t), flags);
+         break;
+       }
       if (flags & TFF_DECL_SPECIFIERS)
        pp_cxx_identifier (cxx_pp, "typedef");
       dump_simple_decl (t, DECL_ORIGINAL_TYPE (t)
                        ? DECL_ORIGINAL_TYPE (t) : TREE_TYPE (t),
-                       flags);
+                       flags);
       break;
 
     case VAR_DECL:
@@ -753,15 +755,15 @@ dump_decl (tree t, int flags)
 
     case NAMESPACE_DECL:
       if (flags & TFF_DECL_SPECIFIERS)
-        pp_cxx_declaration (cxx_pp, t);
+       pp_cxx_declaration (cxx_pp, t);
       else
-        {
-          dump_scope (CP_DECL_CONTEXT (t), flags);
-          if (DECL_NAME (t) == NULL_TREE)
-            pp_identifier (cxx_pp, "<unnamed>");
-          else
-            pp_cxx_tree_identifier (cxx_pp, DECL_NAME (t));
-        }
+       {
+         dump_scope (CP_DECL_CONTEXT (t), flags);
+         if (DECL_NAME (t) == NULL_TREE)
+           pp_identifier (cxx_pp, "<unnamed>");
+         else
+           pp_cxx_tree_identifier (cxx_pp, DECL_NAME (t));
+       }
       break;
 
     case SCOPE_REF:
@@ -784,7 +786,7 @@ dump_decl (tree t, int flags)
 
     case BIT_NOT_EXPR:
       /* This is a pseudo destructor call which has not been folded into
-         a PSEUDO_DTOR_EXPR yet.  */
+        a PSEUDO_DTOR_EXPR yet.  */
       pp_cxx_complement (cxx_pp);
       dump_type (TREE_OPERAND (t, 0), flags);
       break;
@@ -814,17 +816,17 @@ dump_decl (tree t, int flags)
          if (DECL_CLASS_SCOPE_P (t))
            {
              dump_type (DECL_CONTEXT (t), flags);
-              pp_cxx_colon_colon (cxx_pp);
+             pp_cxx_colon_colon (cxx_pp);
            }
          else if (DECL_CONTEXT (t))
            {
              dump_decl (DECL_CONTEXT (t), flags);
-              pp_cxx_colon_colon (cxx_pp);
+             pp_cxx_colon_colon (cxx_pp);
            }
          dump_decl (DECL_NAME (t), flags);
          break;
        }
-      
+
       /* If there's only one function, just treat it like an ordinary
         FUNCTION_DECL.  */
       t = OVL_CURRENT (t);
@@ -836,7 +838,7 @@ dump_decl (tree t, int flags)
       else if (DECL_GLOBAL_CTOR_P (t) || DECL_GLOBAL_DTOR_P (t))
        dump_global_iord (t);
       else
-        dump_function_decl (t, flags);
+       dump_function_decl (t, flags);
       break;
 
     case TEMPLATE_DECL:
@@ -846,7 +848,7 @@ dump_decl (tree t, int flags)
     case TEMPLATE_ID_EXPR:
       {
        tree name = TREE_OPERAND (t, 0);
-       
+
        if (is_overloaded_fn (name))
          name = DECL_NAME (get_first_fn (name));
        dump_decl (name, flags);
@@ -891,9 +893,9 @@ dump_decl (tree t, int flags)
 
     case TEMPLATE_TYPE_PARM:
       if (flags & TFF_DECL_SPECIFIERS)
-        pp_cxx_declaration (cxx_pp, t);
+       pp_cxx_declaration (cxx_pp, t);
       else
-        pp_type_id (cxx_pp, t);
+       pp_type_id (cxx_pp, t);
       break;
 
     default:
@@ -919,28 +921,28 @@ dump_template_decl (tree t, int flags)
   if (flags & TFF_TEMPLATE_HEADER)
     {
       for (parms = orig_parms = nreverse (orig_parms);
-           parms;
-           parms = TREE_CHAIN (parms))
-        {
+          parms;
+          parms = TREE_CHAIN (parms))
+       {
          tree inner_parms = INNERMOST_TEMPLATE_PARMS (parms);
-          int len = TREE_VEC_LENGTH (inner_parms);
+         int len = TREE_VEC_LENGTH (inner_parms);
 
-          pp_cxx_identifier (cxx_pp, "template");
-          pp_cxx_begin_template_argument_list (cxx_pp);
+         pp_cxx_identifier (cxx_pp, "template");
+         pp_cxx_begin_template_argument_list (cxx_pp);
 
          /* If we've shown the template prefix, we'd better show the
             parameters' and decl's type too.  */
            flags |= TFF_DECL_SPECIFIERS;
 
-          for (i = 0; i < len; i++)
-            {
-              if (i)
-                pp_separate_with_comma (cxx_pp);
-              dump_template_parameter (TREE_VEC_ELT (inner_parms, i), flags);
-            }
-          pp_cxx_end_template_argument_list (cxx_pp);
-          pp_cxx_whitespace (cxx_pp);
-        }
+         for (i = 0; i < len; i++)
+           {
+             if (i)
+               pp_separate_with_comma (cxx_pp);
+             dump_template_parameter (TREE_VEC_ELT (inner_parms, i), flags);
+           }
+         pp_cxx_end_template_argument_list (cxx_pp);
+         pp_cxx_whitespace (cxx_pp);
+       }
       nreverse(orig_parms);
 
       if (DECL_TEMPLATE_TEMPLATE_PARM_P (t))
@@ -950,8 +952,8 @@ dump_template_decl (tree t, int flags)
 
   if (TREE_CODE (DECL_TEMPLATE_RESULT (t)) == TYPE_DECL)
     dump_type (TREE_TYPE (t),
-               ((flags & ~TFF_CLASS_KEY_OR_ENUM) | TFF_TEMPLATE_NAME
-                | (flags & TFF_DECL_SPECIFIERS ? TFF_CLASS_KEY_OR_ENUM : 0)));
+              ((flags & ~TFF_CLASS_KEY_OR_ENUM) | TFF_TEMPLATE_NAME
+               | (flags & TFF_DECL_SPECIFIERS ? TFF_CLASS_KEY_OR_ENUM : 0)));
   else if (TREE_CODE (DECL_TEMPLATE_RESULT (t)) == VAR_DECL)
     dump_decl (DECL_TEMPLATE_RESULT (t), flags | TFF_TEMPLATE_NAME);
   else
@@ -1024,7 +1026,7 @@ dump_function_decl (tree t, int flags)
   /* Print the return type?  */
   if (show_return)
     show_return = !DECL_CONV_FN_P (t)  && !DECL_CONSTRUCTOR_P (t)
-                  && !DECL_DESTRUCTOR_P (t);
+                 && !DECL_DESTRUCTOR_P (t);
   if (show_return)
     dump_type_prefix (TREE_TYPE (fntype), flags);
 
@@ -1044,17 +1046,17 @@ dump_function_decl (tree t, int flags)
       dump_parameters (parmtypes, flags);
 
       if (TREE_CODE (fntype) == METHOD_TYPE)
-        {
-          pp_base (cxx_pp)->padding = pp_before;
-          pp_cxx_cv_qualifier_seq
-            (cxx_pp, TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (fntype))));
-        }
+       {
+         pp_base (cxx_pp)->padding = pp_before;
+         pp_cxx_cv_qualifier_seq
+           (cxx_pp, TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (fntype))));
+       }
 
       if (flags & TFF_EXCEPTION_SPECIFICATION)
-        {
-          pp_base (cxx_pp)->padding = pp_before;
-          dump_exception_spec (TYPE_RAISES_EXCEPTIONS (fntype), flags);
-        }
+       {
+         pp_base (cxx_pp)->padding = pp_before;
+         dump_exception_spec (TYPE_RAISES_EXCEPTIONS (fntype), flags);
+       }
 
       if (show_return)
        dump_type_suffix (TREE_TYPE (fntype), flags);
@@ -1087,22 +1089,22 @@ dump_parameters (tree parmtypes, int flags)
        parmtypes = TREE_CHAIN (parmtypes))
     {
       if (!first)
-        pp_separate_with_comma (cxx_pp);
+       pp_separate_with_comma (cxx_pp);
       first = 0;
       if (!parmtypes)
-        {
-          pp_cxx_identifier (cxx_pp, "...");
-          break;
-        }
+       {
+         pp_cxx_identifier (cxx_pp, "...");
+         break;
+       }
       dump_type (TREE_VALUE (parmtypes), flags);
 
       if ((flags & TFF_FUNCTION_DEFAULT_ARGUMENTS) && TREE_PURPOSE (parmtypes))
-        {
-          pp_cxx_whitespace (cxx_pp);
-          pp_equal (cxx_pp);
-          pp_cxx_whitespace (cxx_pp);
-          dump_expr (TREE_PURPOSE (parmtypes), flags | TFF_EXPR_IN_PARENS);
-        }
+       {
+         pp_cxx_whitespace (cxx_pp);
+         pp_equal (cxx_pp);
+         pp_cxx_whitespace (cxx_pp);
+         dump_expr (TREE_PURPOSE (parmtypes), flags | TFF_EXPR_IN_PARENS);
+       }
     }
 
   pp_cxx_right_paren (cxx_pp);
@@ -1119,14 +1121,14 @@ dump_exception_spec (tree t, int flags)
       pp_cxx_whitespace (cxx_pp);
       pp_cxx_left_paren (cxx_pp);
       if (TREE_VALUE (t) != NULL_TREE)
-        while (1)
-          {
-            dump_type (TREE_VALUE (t), flags);
-            t = TREE_CHAIN (t);
-            if (!t)
-              break;
-            pp_separate_with_comma (cxx_pp);
-          }
+       while (1)
+         {
+           dump_type (TREE_VALUE (t), flags);
+           t = TREE_CHAIN (t);
+           if (!t)
+             break;
+           pp_separate_with_comma (cxx_pp);
+         }
       pp_cxx_right_paren (cxx_pp);
     }
 }
@@ -1212,21 +1214,21 @@ dump_template_parms (tree info, int primary, int flags)
 
       if (TMPL_ARGS_HAVE_MULTIPLE_LEVELS (args))
        args = TREE_VEC_ELT (args, TREE_VEC_LENGTH (args) - 1);
-      
+
       len = TREE_VEC_LENGTH (args);
 
       for (ix = 0; ix != len; ix++)
-        {
-          tree arg = TREE_VEC_ELT (args, ix);
-
-          if (ix)
-            pp_separate_with_comma (cxx_pp);
-          
-          if (!arg)
-            pp_identifier (cxx_pp, "<template parameter error>");
-          else
-            dump_template_argument (arg, flags);
-        }
+       {
+         tree arg = TREE_VEC_ELT (args, ix);
+
+         if (ix)
+           pp_separate_with_comma (cxx_pp);
+
+         if (!arg)
+           pp_identifier (cxx_pp, "<template parameter error>");
+         else
+           dump_template_argument (arg, flags);
+       }
     }
   else if (primary)
     {
@@ -1238,14 +1240,14 @@ dump_template_parms (tree info, int primary, int flags)
       len = parms ? TREE_VEC_LENGTH (parms) : 0;
 
       for (ix = 0; ix != len; ix++)
-        {
-          tree parm = TREE_VALUE (TREE_VEC_ELT (parms, ix));
+       {
+         tree parm = TREE_VALUE (TREE_VEC_ELT (parms, ix));
 
-          if (ix)
-            pp_separate_with_comma (cxx_pp);
+         if (ix)
+           pp_separate_with_comma (cxx_pp);
 
-          dump_decl (parm, flags & ~TFF_DECL_SPECIFIERS);
-        }
+         dump_decl (parm, flags & ~TFF_DECL_SPECIFIERS);
+       }
     }
   pp_cxx_end_template_argument_list (cxx_pp);
 }
@@ -1271,7 +1273,7 @@ dump_expr (tree t, int flags)
 {
   if (t == 0)
     return;
-  
+
   switch (TREE_CODE (t))
     {
     case VAR_DECL:
@@ -1286,8 +1288,15 @@ dump_expr (tree t, int flags)
       dump_decl (t, (flags & ~TFF_DECL_SPECIFIERS) | TFF_NO_FUNCTION_ARGUMENTS);
       break;
 
-    case INTEGER_CST:
     case STRING_CST:
+      if (PAREN_STRING_LITERAL_P (t))
+       pp_cxx_left_paren (cxx_pp);
+      pp_c_constant (pp_c_base (cxx_pp), t);
+      if (PAREN_STRING_LITERAL_P (t))
+       pp_cxx_right_paren (cxx_pp);
+      break;
+
+    case INTEGER_CST:
     case REAL_CST:
        pp_c_constant (pp_c_base (cxx_pp), t);
       break;
@@ -1326,11 +1335,11 @@ dump_expr (tree t, int flags)
       if (TREE_HAS_CONSTRUCTOR (t))
        {
          pp_cxx_identifier (cxx_pp, "new");
-          pp_cxx_whitespace (cxx_pp);
+         pp_cxx_whitespace (cxx_pp);
          dump_type (TREE_TYPE (TREE_TYPE (t)), flags);
        }
       else
-        dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
+       dump_expr (TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS);
       break;
 
     case AGGR_INIT_EXPR:
@@ -1392,21 +1401,21 @@ dump_expr (tree t, int flags)
        tree type = TREE_OPERAND (t, 1);
        tree init = TREE_OPERAND (t, 2);
        if (NEW_EXPR_USE_GLOBAL (t))
-          pp_cxx_colon_colon (cxx_pp);
+         pp_cxx_colon_colon (cxx_pp);
        pp_cxx_identifier (cxx_pp, "new");
        if (TREE_OPERAND (t, 0))
          {
            pp_cxx_left_paren (cxx_pp);
            dump_expr_list (TREE_OPERAND (t, 0), flags);
-            pp_cxx_right_paren (cxx_pp);
-            pp_cxx_whitespace (cxx_pp);
+           pp_cxx_right_paren (cxx_pp);
+           pp_cxx_whitespace (cxx_pp);
          }
        if (TREE_CODE (type) == ARRAY_REF)
          type = build_cplus_array_type
            (TREE_OPERAND (type, 0),
-            build_index_type (fold (build2 (MINUS_EXPR, integer_type_node,
-                                            TREE_OPERAND (type, 1),
-                                            integer_one_node))));
+            build_index_type (fold_build2 (MINUS_EXPR, integer_type_node,
+                                           TREE_OPERAND (type, 1),
+                                           integer_one_node)));
        dump_type (type, flags);
        if (init)
          {
@@ -1480,7 +1489,8 @@ dump_expr (tree t, int flags)
          {
            ob = TREE_OPERAND (ob, 0);
            if (TREE_CODE (ob) != PARM_DECL
-               || strcmp (IDENTIFIER_POINTER (DECL_NAME (ob)), "this"))
+               || (DECL_NAME (ob)
+                   && strcmp (IDENTIFIER_POINTER (DECL_NAME (ob)), "this")))
              {
                dump_expr (ob, flags | TFF_EXPR_IN_PARENS);
                pp_cxx_arrow (cxx_pp);
@@ -1502,16 +1512,8 @@ dump_expr (tree t, int flags)
       pp_cxx_right_bracket (cxx_pp);
       break;
 
-    case CONVERT_EXPR:
-      if (TREE_TYPE (t) && VOID_TYPE_P (TREE_TYPE (t)))
-       {
-         pp_cxx_left_paren (cxx_pp);
-         dump_type (TREE_TYPE (t), flags);
-         pp_cxx_right_paren (cxx_pp);
-         dump_expr (TREE_OPERAND (t, 0), flags);
-       }
-      else
-       dump_unary_op ("+", t, flags);
+    case UNARY_PLUS_EXPR:
+      dump_unary_op ("+", t, flags);
       break;
 
     case ADDR_EXPR:
@@ -1578,11 +1580,11 @@ dump_expr (tree t, int flags)
          if (TREE_CODE (next) == FUNCTION_TYPE)
            {
              if (flags & TFF_EXPR_IN_PARENS)
-               pp_cxx_left_paren (cxx_pp);
+               pp_cxx_left_paren (cxx_pp);
              pp_cxx_star (cxx_pp);
              dump_expr (TREE_OPERAND (t, 0), flags & ~TFF_EXPR_IN_PARENS);
              if (flags & TFF_EXPR_IN_PARENS)
-               pp_cxx_right_paren (cxx_pp);
+               pp_cxx_right_paren (cxx_pp);
              break;
            }
          /* Else fall through.  */
@@ -1591,9 +1593,10 @@ dump_expr (tree t, int flags)
       break;
 
     case NOP_EXPR:
+    case CONVERT_EXPR:
       {
        tree op = TREE_OPERAND (t, 0);
-       
+
        if (!same_type_p (TREE_TYPE (op), TREE_TYPE (t)))
          {
            /* It is a cast, but we cannot tell whether it is a
@@ -1611,7 +1614,7 @@ dump_expr (tree t, int flags)
          dump_expr (op, flags);
        break;
       }
-      
+
     case CONSTRUCTOR:
       if (TREE_TYPE (t) && TYPE_PTRMEMFUNC_P (TREE_TYPE (t)))
        {
@@ -1620,12 +1623,12 @@ dump_expr (tree t, int flags)
          if (integer_zerop (idx))
            {
              /* A NULL pointer-to-member constant.  */
-              pp_cxx_left_paren (cxx_pp);
-              pp_cxx_left_paren (cxx_pp);
+             pp_cxx_left_paren (cxx_pp);
+             pp_cxx_left_paren (cxx_pp);
              dump_type (TREE_TYPE (t), flags);
-              pp_cxx_right_paren (cxx_pp);
-              pp_character (cxx_pp, '0');
-              pp_cxx_right_paren (cxx_pp);
+             pp_cxx_right_paren (cxx_pp);
+             pp_character (cxx_pp, '0');
+             pp_cxx_right_paren (cxx_pp);
              break;
            }
          else if (host_integerp (idx, 0))
@@ -1651,7 +1654,7 @@ dump_expr (tree t, int flags)
              if (virtuals)
                {
                  dump_expr (BV_FN (virtuals),
-                            flags | TFF_EXPR_IN_PARENS);
+                            flags | TFF_EXPR_IN_PARENS);
                  break;
                }
            }
@@ -1659,16 +1662,16 @@ dump_expr (tree t, int flags)
       if (TREE_TYPE (t) && !CONSTRUCTOR_ELTS (t))
        {
          dump_type (TREE_TYPE (t), 0);
-          pp_cxx_left_paren (cxx_pp);
-          pp_cxx_right_paren (cxx_pp);
+         pp_cxx_left_paren (cxx_pp);
+         pp_cxx_right_paren (cxx_pp);
        }
       else
        {
-          pp_cxx_left_brace (cxx_pp);
+         pp_cxx_left_brace (cxx_pp);
          dump_expr_list (CONSTRUCTOR_ELTS (t), flags);
-          pp_cxx_right_brace (cxx_pp);
+         pp_cxx_right_brace (cxx_pp);
        }
-      
+
       break;
 
     case OFFSET_REF:
@@ -1681,7 +1684,7 @@ dump_expr (tree t, int flags)
              /* A::f */
              dump_expr (t, flags | TFF_EXPR_IN_PARENS);
            else if (BASELINK_P (t))
-             dump_expr (OVL_CURRENT (BASELINK_FUNCTIONS (t)), 
+             dump_expr (OVL_CURRENT (BASELINK_FUNCTIONS (t)),
                         flags | TFF_EXPR_IN_PARENS);
            else
              dump_decl (t, flags);
@@ -1691,14 +1694,14 @@ dump_expr (tree t, int flags)
            if (TREE_CODE (ob) == INDIRECT_REF)
              {
                dump_expr (TREE_OPERAND (ob, 0), flags | TFF_EXPR_IN_PARENS);
-                pp_cxx_arrow (cxx_pp);
-                pp_cxx_star (cxx_pp);
+               pp_cxx_arrow (cxx_pp);
+               pp_cxx_star (cxx_pp);
              }
            else
              {
                dump_expr (ob, flags | TFF_EXPR_IN_PARENS);
-                pp_cxx_dot (cxx_pp);
-                pp_cxx_star (cxx_pp);
+               pp_cxx_dot (cxx_pp);
+               pp_cxx_star (cxx_pp);
              }
            dump_expr (TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS);
          }
@@ -1726,8 +1729,8 @@ dump_expr (tree t, int flags)
        {
          pp_cxx_left_paren (cxx_pp);
          dump_type (TREE_TYPE (t), flags);
-          pp_cxx_right_paren (cxx_pp);
-          pp_cxx_left_paren (cxx_pp);
+         pp_cxx_right_paren (cxx_pp);
+         pp_cxx_left_paren (cxx_pp);
          dump_expr_list (TREE_OPERAND (t, 0), flags);
          pp_cxx_right_paren (cxx_pp);
        }
@@ -1761,7 +1764,7 @@ dump_expr (tree t, int flags)
     case SIZEOF_EXPR:
     case ALIGNOF_EXPR:
       if (TREE_CODE (t) == SIZEOF_EXPR)
-        pp_cxx_identifier (cxx_pp, "sizeof");
+       pp_cxx_identifier (cxx_pp, "sizeof");
       else
        {
          gcc_assert (TREE_CODE (t) == ALIGNOF_EXPR);
@@ -1772,7 +1775,7 @@ dump_expr (tree t, int flags)
       if (TYPE_P (TREE_OPERAND (t, 0)))
        dump_type (TREE_OPERAND (t, 0), flags);
       else
-        dump_expr (TREE_OPERAND (t, 0), flags);
+       dump_expr (TREE_OPERAND (t, 0), flags);
       pp_cxx_right_paren (cxx_pp);
       break;
 
@@ -1806,18 +1809,14 @@ dump_expr (tree t, int flags)
       dump_decl (t, flags);
       break;
 
+    case BIND_EXPR:
     case STMT_EXPR:
+    case STATEMENT_LIST:
       /* We don't yet have a way of dumping statements in a
         human-readable format.  */
       pp_string (cxx_pp, "({...})");
       break;
 
-    case BIND_EXPR:
-      pp_cxx_left_brace (cxx_pp);
-      dump_expr (TREE_OPERAND (t, 1), flags & ~TFF_EXPR_IN_PARENS);
-      pp_cxx_right_brace (cxx_pp);
-      break;
-
     case LOOP_EXPR:
       pp_string (cxx_pp, "while (1) { ");
       dump_expr (TREE_OPERAND (t, 0), flags & ~TFF_EXPR_IN_PARENS);
@@ -1920,14 +1919,6 @@ decl_as_string (tree decl, int flags)
   return pp_formatted_text (cxx_pp);
 }
 
-const char *
-context_as_string (tree context, int flags)
-{
-  reinit_cxx_pp ();
-  dump_scope (context, flags);
-  return pp_formatted_text (cxx_pp);
-}
-
 /* Generate the three forms of printable names for cxx_printable_name.  */
 
 const char *
@@ -1960,7 +1951,7 @@ location_of (tree t)
     t = TYPE_MAIN_DECL (t);
   else if (TREE_CODE (t) == OVERLOAD)
     t = OVL_FUNCTION (t);
-  
+
   return DECL_SOURCE_LOCATION (t);
 }
 
@@ -2121,7 +2112,7 @@ cxx_print_error_function (diagnostic_context *context, const char *file)
 
 static void
 cp_diagnostic_starter (diagnostic_context *context,
-                       diagnostic_info *diagnostic)
+                      diagnostic_info *diagnostic)
 {
   diagnostic_report_current_module (context);
   cp_print_error_function (context, diagnostic);
@@ -2131,7 +2122,7 @@ cp_diagnostic_starter (diagnostic_context *context,
 
 static void
 cp_diagnostic_finalizer (diagnostic_context *context,
-                         diagnostic_info *diagnostic ATTRIBUTE_UNUSED)
+                        diagnostic_info *diagnostic ATTRIBUTE_UNUSED)
 {
   pp_base_destroy_prefix (context->printer);
 }
@@ -2140,7 +2131,7 @@ cp_diagnostic_finalizer (diagnostic_context *context,
    a diagnostic message.  Called from cp_diagnostic_starter.  */
 static void
 cp_print_error_function (diagnostic_context *context,
-                         diagnostic_info *diagnostic)
+                        diagnostic_info *diagnostic)
 {
   if (diagnostic_last_function_changed (context))
     {
@@ -2151,11 +2142,11 @@ cp_print_error_function (diagnostic_context *context,
       pp_base_set_prefix (context->printer, new_prefix);
 
       if (current_function_decl == NULL)
-        pp_base_string (context->printer, "At global scope:");
+       pp_base_string (context->printer, "At global scope:");
       else
-        pp_printf (context->printer, "In %s `%s':",
-                   function_category (current_function_decl),
-                   cxx_printable_name (current_function_decl, 2));
+       pp_printf (context->printer, "In %s %qs:",
+                  function_category (current_function_decl),
+                  cxx_printable_name (current_function_decl, 2));
       pp_base_newline (context->printer);
 
       diagnostic_set_last_function (context);
@@ -2171,15 +2162,15 @@ function_category (tree fn)
   if (DECL_FUNCTION_MEMBER_P (fn))
     {
       if (DECL_STATIC_FUNCTION_P (fn))
-        return "static member function";
+       return "static member function";
       else if (DECL_COPY_CONSTRUCTOR_P (fn))
-        return "copy constructor";
+       return "copy constructor";
       else if (DECL_CONSTRUCTOR_P (fn))
-        return "constructor";
+       return "constructor";
       else if (DECL_DESTRUCTOR_P (fn))
-        return "destructor";
+       return "destructor";
       else
-        return "member function";
+       return "member function";
     }
   else
     return "function";
@@ -2192,7 +2183,7 @@ print_instantiation_full_context (diagnostic_context *context)
 {
   tree p = current_instantiation ();
   location_t location = input_location;
-  
+
   if (p)
     {
       if (current_function_decl != TINST_DECL (p)
@@ -2204,13 +2195,13 @@ print_instantiation_full_context (diagnostic_context *context)
       else
        {
          if (current_function_decl == TINST_DECL (p))
-           /* Avoid redundancy with the the "In function" line.  */;
+           /* Avoid redundancy with the "In function" line.  */;
          else
            pp_verbatim (context->printer,
-                         "%s: In instantiation of `%s':\n",
+                        "%s: In instantiation of %qs:\n",
                         LOCATION_FILE (location),
-                         decl_as_string (TINST_DECL (p),
-                                         TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE));
+                        decl_as_string (TINST_DECL (p),
+                                        TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE));
 
          location = TINST_LOCATION (p);
          p = TREE_CHAIN (p);
@@ -2223,7 +2214,7 @@ print_instantiation_full_context (diagnostic_context *context)
 /* Same as above but less verbose.  */
 static void
 print_instantiation_partial_context (diagnostic_context *context,
-                                     tree t, location_t loc)
+                                    tree t, location_t loc)
 {
   expanded_location xloc;
   for (; ; t = TREE_CHAIN (t))
@@ -2231,14 +2222,14 @@ print_instantiation_partial_context (diagnostic_context *context,
       xloc = expand_location (loc);
       if (t == NULL_TREE)
        break;
-      pp_verbatim (context->printer, "%s:%d:   instantiated from `%s'\n",
-                   xloc.file, xloc.line,
-                   decl_as_string (TINST_DECL (t),
-                                   TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE));
+      pp_verbatim (context->printer, "%s:%d:   instantiated from %qs\n",
+                  xloc.file, xloc.line,
+                  decl_as_string (TINST_DECL (t),
+                                  TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE));
       loc = TINST_LOCATION (t);
     }
   pp_verbatim (context->printer, "%s:%d:   instantiated from here\n",
-               xloc.file, xloc.line);
+              xloc.file, xloc.line);
 }
 
 /* Called from cp_thing to print the template context for an error.  */
@@ -2295,17 +2286,17 @@ cp_printer (pretty_printer *pp, text_info *text)
   switch (*text->format_spec)
     {
     case 'A': result = args_to_string (next_tree, verbose);    break;
-    case 'C': result = code_to_string (next_tcode);            break;
+    case 'C': result = code_to_string (next_tcode);            break;
     case 'D': result = decl_to_string (next_tree, verbose);    break;
-    case 'E': result = expr_to_string (next_tree);             break;
+    case 'E': result = expr_to_string (next_tree);             break;
     case 'F': result = fndecl_to_string (next_tree, verbose);  break;
-    case 'L': result = language_to_string (next_lang);          break;
-    case 'O': result = op_to_string (next_tcode);              break;
-    case 'P': result = parm_to_string (next_int);              break;
-    case 'Q': result = assop_to_string (next_tcode);           break;
+    case 'L': result = language_to_string (next_lang);         break;
+    case 'O': result = op_to_string (next_tcode);              break;
+    case 'P': result = parm_to_string (next_int);              break;
+    case 'Q': result = assop_to_string (next_tcode);           break;
     case 'T': result = type_to_string (next_tree, verbose);    break;
     case 'V': result = cv_to_string (next_tree, verbose);      break;
+
     default:
       return false;
     }
@@ -2322,25 +2313,25 @@ cp_printer (pretty_printer *pp, text_info *text)
    behavior of cp_*_at.  */
 
 static tree
-locate_error (const char *msgid, va_list ap)
+locate_error (const char *gmsgid, va_list ap)
 {
   tree here = 0, t;
   int plus = 0;
   const char *f;
 
-  for (f = msgid; *f; f++)
+  for (f = gmsgid; *f; f++)
     {
       plus = 0;
       if (*f == '%')
        {
-          if (*++f == 'q')
-            ++f;                /* ignore quoting flag.  */
+         if (*++f == 'q')
+           ++f;                        /* ignore quoting flag.  */
 
          if (*f == '+')
-            {
-              ++f;
-              plus = 1;
-            }
+           {
+             ++f;
+             plus = 1;
+           }
          if (*f == '#')
            f++;
 
@@ -2371,7 +2362,7 @@ locate_error (const char *msgid, va_list ap)
 
            default:
              errorcount = 0;  /* damn ICE suppression */
-             internal_error ("unexpected letter `%c' in locate_error\n", *f);
+             internal_error ("unexpected letter %qc in locate_error\n", *f);
            }
        }
     }
@@ -2384,58 +2375,58 @@ locate_error (const char *msgid, va_list ap)
 
 
 void
-cp_error_at (const char *msgid, ...)
+cp_error_at (const char *gmsgid, ...)
 {
   tree here;
   diagnostic_info diagnostic;
   va_list ap;
 
-  va_start (ap, msgid);
-  here = locate_error (msgid, ap);
+  va_start (ap, gmsgid);
+  here = locate_error (gmsgid, ap);
   va_end (ap);
 
-  va_start (ap, msgid);
-  diagnostic_set_info (&diagnostic, msgid, &ap,
-                       input_location, DK_ERROR);
+  va_start (ap, gmsgid);
+  diagnostic_set_info (&diagnostic, gmsgid, &ap,
+                      input_location, DK_ERROR);
   cp_diagnostic_starter (global_dc, &diagnostic);
-  diagnostic_set_info (&diagnostic, msgid, &ap,
-                       location_of (here), DK_ERROR);
+  diagnostic_set_info (&diagnostic, gmsgid, &ap,
+                      location_of (here), DK_ERROR);
   report_diagnostic (&diagnostic);
   va_end (ap);
 }
 
 void
-cp_warning_at (const char *msgid, ...)
+cp_warning_at (const char *gmsgid, ...)
 {
   tree here;
   diagnostic_info diagnostic;
   va_list ap;
 
-  va_start (ap, msgid);
-  here = locate_error (msgid, ap);
+  va_start (ap, gmsgid);
+  here = locate_error (gmsgid, ap);
   va_end (ap);
 
-  va_start (ap, msgid);
-  diagnostic_set_info (&diagnostic, msgid, &ap,
-                       location_of (here), DK_WARNING);
+  va_start (ap, gmsgid);
+  diagnostic_set_info (&diagnostic, gmsgid, &ap,
+                      location_of (here), DK_WARNING);
   report_diagnostic (&diagnostic);
   va_end (ap);
 }
 
 void
-cp_pedwarn_at (const char *msgid, ...)
+cp_pedwarn_at (const char *gmsgid, ...)
 {
   tree here;
   diagnostic_info diagnostic;
   va_list ap;
 
-  va_start (ap, msgid);
-  here = locate_error (msgid, ap);
+  va_start (ap, gmsgid);
+  here = locate_error (gmsgid, ap);
   va_end (ap);
 
-  va_start (ap, msgid);
-  diagnostic_set_info (&diagnostic, msgid, &ap,
-                       location_of (here), pedantic_error_kind());
+  va_start (ap, gmsgid);
+  diagnostic_set_info (&diagnostic, gmsgid, &ap,
+                      location_of (here), pedantic_error_kind());
   report_diagnostic (&diagnostic);
   va_end (ap);
 }