OSDN Git Service

Fix context handling of alias-declaration
[pf3gnuchains/gcc-fork.git] / gcc / cp / error.c
index 544c4d1..d2b6a62 100644 (file)
@@ -61,6 +61,7 @@ static const char *op_to_string       (enum tree_code);
 static const char *parm_to_string (int);
 static const char *type_to_string (tree, int);
 
+static void dump_alias_template_specialization (tree, int);
 static void dump_type (tree, int);
 static void dump_typename (tree, int);
 static void dump_simple_decl (tree, tree, int);
@@ -330,6 +331,25 @@ dump_template_bindings (tree parms, tree args, VEC(tree,gc)* typenames)
     }
 }
 
+/* Dump a human-readable equivalent of the alias template
+   specialization of T.  */
+
+static void
+dump_alias_template_specialization (tree t, int flags)
+{
+  tree name;
+
+  gcc_assert (alias_template_specialization_p (t));
+
+  if (!(flags & TFF_UNQUALIFIED_NAME))
+    dump_scope (CP_DECL_CONTEXT (TYPE_NAME (t)), flags);
+  name = TYPE_IDENTIFIER (t);
+  pp_cxx_tree_identifier (cxx_pp, name);
+  dump_template_parms (TYPE_TEMPLATE_INFO (t),
+                      /*primary=*/false,
+                      flags & ~TFF_TEMPLATE_HEADER);
+}
+
 /* Dump a human-readable equivalent of TYPE.  FLAGS controls the
    format.  */
 
@@ -344,10 +364,15 @@ dump_type (tree t, int flags)
     {
       tree decl = TYPE_NAME (t);
       if ((flags & TFF_CHASE_TYPEDEF)
-         || DECL_SELF_REFERENCE_P (decl)
-         || (!flag_pretty_templates
-             && DECL_LANG_SPECIFIC (decl) && DECL_TEMPLATE_INFO (decl)))
+              || DECL_SELF_REFERENCE_P (decl)
+              || (!flag_pretty_templates
+                  && DECL_LANG_SPECIFIC (decl) && DECL_TEMPLATE_INFO (decl)))
        t = strip_typedefs (t);
+      else if (alias_template_specialization_p (t))
+       {
+         dump_alias_template_specialization (t, flags);
+         return;
+       }
       else if (same_type_p (t, TREE_TYPE (decl)))
        t = decl;
       else
@@ -588,7 +613,10 @@ dump_aggr_type (tree t, int flags)
 
   if (name)
     {
-      typdef = !DECL_ARTIFICIAL (name);
+      typdef = (!DECL_ARTIFICIAL (name)
+               /* An alias specialization is not considered to be a
+                  typedef.  */
+               && !alias_template_specialization_p (t));
 
       if ((typdef
           && ((flags & TFF_CHASE_TYPEDEF)
@@ -613,7 +641,7 @@ dump_aggr_type (tree t, int flags)
        {
          /* Because the template names are mangled, we have to locate
             the most general template, and use that name.  */
-         tree tpl = CLASSTYPE_TI_TEMPLATE (t);
+         tree tpl = TYPE_TI_TEMPLATE (t);
 
          while (DECL_TEMPLATE_INFO (tpl))
            tpl = DECL_TI_TEMPLATE (tpl);
@@ -952,6 +980,18 @@ dump_decl (tree t, int flags)
          dump_type (TREE_TYPE (t), flags);
          break;
        }
+      if (TYPE_DECL_ALIAS_P (t)
+         && (flags & TFF_DECL_SPECIFIERS
+             || flags & TFF_CLASS_KEY_OR_ENUM))
+       {
+         pp_cxx_ws_string (cxx_pp, "using");
+         dump_decl (DECL_NAME (t), flags);
+         pp_cxx_whitespace (cxx_pp);
+         pp_cxx_ws_string (cxx_pp, "=");
+         pp_cxx_whitespace (cxx_pp);
+         dump_type (DECL_ORIGINAL_TYPE (t), flags);
+         break;
+       }
       if ((flags & TFF_DECL_SPECIFIERS)
          && !DECL_SELF_REFERENCE_P (t))
        pp_cxx_ws_string (cxx_pp, "typedef");
@@ -1196,13 +1236,14 @@ dump_template_decl (tree t, int flags)
        }
     }
 
-  if (DECL_TEMPLATE_RESULT (t)
-      && TREE_CODE (DECL_TEMPLATE_RESULT (t)) == TYPE_DECL)
+  if (DECL_CLASS_TEMPLATE_P (t))
     dump_type (TREE_TYPE (t),
               ((flags & ~TFF_CLASS_KEY_OR_ENUM) | TFF_TEMPLATE_NAME
                | (flags & TFF_DECL_SPECIFIERS ? TFF_CLASS_KEY_OR_ENUM : 0)));
   else if (DECL_TEMPLATE_RESULT (t)
-           && TREE_CODE (DECL_TEMPLATE_RESULT (t)) == VAR_DECL)
+           && (TREE_CODE (DECL_TEMPLATE_RESULT (t)) == VAR_DECL
+              /* Alias template.  */
+              || DECL_TYPE_TEMPLATE_P (t)))
     dump_decl (DECL_TEMPLATE_RESULT (t), flags | TFF_TEMPLATE_NAME);
   else
     {
@@ -3205,55 +3246,55 @@ maybe_warn_cpp0x (cpp0x_warn_str str)
       case CPP0X_INITIALIZER_LISTS:
        pedwarn (input_location, 0, 
                 "extended initializer lists "
-                "only available with -std=c++0x or -std=gnu++0x");
+                "only available with -std=c++11 or -std=gnu++11");
        break;
       case CPP0X_EXPLICIT_CONVERSION:
        pedwarn (input_location, 0,
                 "explicit conversion operators "
-                "only available with -std=c++0x or -std=gnu++0x"); 
+                "only available with -std=c++11 or -std=gnu++11");
        break;
       case CPP0X_VARIADIC_TEMPLATES:
        pedwarn (input_location, 0,
                 "variadic templates "
-                "only available with -std=c++0x or -std=gnu++0x");
+                "only available with -std=c++11 or -std=gnu++11");
        break;
       case CPP0X_LAMBDA_EXPR:
        pedwarn (input_location, 0,
                 "lambda expressions "
-                 "only available with -std=c++0x or -std=gnu++0x");
+                 "only available with -std=c++11 or -std=gnu++11");
        break;
       case CPP0X_AUTO:
        pedwarn (input_location, 0,
-                "C++0x auto only available with -std=c++0x or -std=gnu++0x");
+                "C++0x auto only available with -std=c++11 or -std=gnu++11");
        break;
       case CPP0X_SCOPED_ENUMS:
        pedwarn (input_location, 0,
-                "scoped enums only available with -std=c++0x or -std=gnu++0x");
+                "scoped enums only available with -std=c++11 or -std=gnu++11");
        break;
       case CPP0X_DEFAULTED_DELETED:
        pedwarn (input_location, 0,
                 "defaulted and deleted functions "
-                "only available with -std=c++0x or -std=gnu++0x");
+                "only available with -std=c++11 or -std=gnu++11");
        break;
       case CPP0X_INLINE_NAMESPACES:
        pedwarn (input_location, OPT_pedantic,
                 "inline namespaces "
-                "only available with -std=c++0x or -std=gnu++0x");
+                "only available with -std=c++11 or -std=gnu++11");
        break;
       case CPP0X_OVERRIDE_CONTROLS:
        pedwarn (input_location, 0,
                 "override controls (override/final) "
-                "only available with -std=c++0x or -std=gnu++0x");
+                "only available with -std=c++11 or -std=gnu++11");
         break;
       case CPP0X_NSDMI:
        pedwarn (input_location, 0,
                 "non-static data member initializers "
-                "only available with -std=c++0x or -std=gnu++0x");
+                "only available with -std=c++11 or -std=gnu++11");
         break;
       case CPP0X_USER_DEFINED_LITERALS:
        pedwarn (input_location, 0,
                 "user-defined literals "
-                "only available with -std=c++0x or -std=gnu++0x");
+                "only available with -std=c++11 or -std=gnu++11");
        break;
       default:
        gcc_unreachable ();