OSDN Git Service

* cp-tree.h (struct tinst_level): Add chain_next GTY
[pf3gnuchains/gcc-fork.git] / gcc / cp / error.c
index e580fd9..d9652dc 100644 (file)
@@ -307,13 +307,20 @@ dump_template_bindings (tree parms, tree args, VEC(tree,gc)* typenames)
 
   FOR_EACH_VEC_ELT (tree, typenames, i, t)
     {
+      bool dependent = uses_template_parms (args);
       if (need_comma)
        pp_separate_with_comma (cxx_pp);
       dump_type (t, TFF_PLAIN_IDENTIFIER);
       pp_cxx_whitespace (cxx_pp);
       pp_equal (cxx_pp);
       pp_cxx_whitespace (cxx_pp);
+      push_deferring_access_checks (dk_no_check);
+      if (dependent)
+       ++processing_template_decl;
       t = tsubst (t, args, tf_none, NULL_TREE);
+      if (dependent)
+       --processing_template_decl;
+      pop_deferring_access_checks ();
       /* Strip typedefs.  We can't just use TFF_CHASE_TYPEDEF because
         pp_simple_type_specifier doesn't know about it.  */
       t = strip_typedefs (t);
@@ -1883,7 +1890,10 @@ dump_expr (tree t, int flags)
                    && strcmp (IDENTIFIER_POINTER (DECL_NAME (ob)), "this")))
              {
                dump_expr (ob, flags | TFF_EXPR_IN_PARENS);
-               pp_cxx_arrow (cxx_pp);
+               if (TREE_CODE (TREE_TYPE (ob)) == REFERENCE_TYPE)
+                 pp_cxx_dot (cxx_pp);
+               else
+                 pp_cxx_arrow (cxx_pp);
              }
          }
        else
@@ -2655,6 +2665,32 @@ args_to_string (tree p, int verbose)
   return pp_formatted_text (cxx_pp);
 }
 
+/* Pretty-print a deduction substitution (from deduction_tsubst_fntype).  P
+   is a TREE_LIST with purpose the TEMPLATE_DECL, value the template
+   arguments.  */
+
+static const char *
+subst_to_string (tree p)
+{
+  tree decl = TREE_PURPOSE (p);
+  tree targs = TREE_VALUE (p);
+  tree tparms = DECL_TEMPLATE_PARMS (decl);
+  int flags = TFF_DECL_SPECIFIERS|TFF_TEMPLATE_HEADER;
+
+  if (p == NULL_TREE)
+    return "";
+
+  reinit_cxx_pp ();
+  dump_template_decl (TREE_PURPOSE (p), flags);
+  pp_cxx_whitespace (cxx_pp);
+  pp_cxx_left_bracket (cxx_pp);
+  pp_cxx_ws_string (cxx_pp, M_("with"));
+  pp_cxx_whitespace (cxx_pp);
+  dump_template_bindings (tparms, targs, NULL);
+  pp_cxx_right_bracket (cxx_pp);
+  return pp_formatted_text (cxx_pp);
+}
+
 static const char *
 cv_to_string (tree p, int v)
 {
@@ -2878,38 +2914,34 @@ print_instantiation_partial_context_line (diagnostic_context *context,
   expanded_location xloc;
   xloc = expand_location (loc);
 
-  if (t != NULL) 
+  if (context->show_column)
+    pp_verbatim (context->printer, _("%s:%d:%d:   "),
+                xloc.file, xloc.line, xloc.column);
+  else
+    pp_verbatim (context->printer, _("%s:%d:   "),
+                xloc.file, xloc.line);
+
+  if (t != NULL)
     {
-      const char *str;
-      str = decl_as_string_translate (t->decl,
-                                     TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE);
-      if (context->show_column)
+      if (TREE_CODE (t->decl) == TREE_LIST)
        pp_verbatim (context->printer,
                     recursive_p
-                    ? _("%s:%d:%d:   recursively instantiated from %qs\n")
-                    : _("%s:%d:%d:   instantiated from %qs\n"),
-                    xloc.file, xloc.line, xloc.column, str);
+                    ? _("recursively required by substitution of %qS\n")
+                    : _("required by substitution of %qS\n"),
+                    t->decl);
       else
        pp_verbatim (context->printer,
                     recursive_p
-                    ? _("%s:%d:   recursively instantiated from %qs\n")
-                    : _("%s:%d:   recursively instantiated from %qs\n"),
-                    xloc.file, xloc.line, str);
+                    ? _("recursively required from %q#D\n")
+                    : _("required from %q#D\n"),
+                    t->decl);
     }
   else
     {
-      if (context->show_column)
-       pp_verbatim (context->printer, 
-                    recursive_p
-                    ? _("%s:%d:%d:   recursively instantiated from here")
-                    : _("%s:%d:%d:   instantiated from here"),
-                    xloc.file, xloc.line, xloc.column);
-      else
-       pp_verbatim (context->printer,
-                    recursive_p
-                    ? _("%s:%d:   recursively instantiated from here")
-                    : _("%s:%d:   instantiated from here"),
-                    xloc.file, xloc.line);
+      pp_verbatim (context->printer,
+                  recursive_p
+                  ? _("recursively required from here")
+                  : _("required from here"));
     }
 }
 
@@ -3083,6 +3115,7 @@ cp_printer (pretty_printer *pp, text_info *text, const char *spec,
     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 'S': result = subst_to_string (next_tree);            break;
     case 'T': result = type_to_string (next_tree, verbose);    break;
     case 'V': result = cv_to_string (next_tree, verbose);      break;