OSDN Git Service

Prevent sharing of commit calls among transactions.
[pf3gnuchains/gcc-fork.git] / gcc / cp / error.c
index 598ddf1..21d6781 100644 (file)
@@ -36,6 +36,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "c-family/c-objc.h"
 
 #define pp_separate_with_comma(PP) pp_cxx_separate_with (PP, ',')
+#define pp_separate_with_semicolon(PP) pp_cxx_separate_with (PP, ';')
 
 /* The global buffer where we dump everything.  It is there only for
    transitional purpose.  It is expected, in the near future, to be
@@ -60,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);
@@ -259,7 +261,7 @@ dump_template_parameter (tree parm, int flags)
 static void
 dump_template_bindings (tree parms, tree args, VEC(tree,gc)* typenames)
 {
-  int need_comma = 0;
+  bool need_semicolon = false;
   int i;
   tree t;
 
@@ -283,8 +285,8 @@ dump_template_bindings (tree parms, tree args, VEC(tree,gc)* typenames)
          if (lvl_args && NUM_TMPL_ARGS (lvl_args) > arg_idx)
            arg = TREE_VEC_ELT (lvl_args, arg_idx);
 
-         if (need_comma)
-           pp_separate_with_comma (cxx_pp);
+         if (need_semicolon)
+           pp_separate_with_semicolon (cxx_pp);
          dump_template_parameter (TREE_VEC_ELT (p, i), TFF_PLAIN_IDENTIFIER);
          pp_cxx_whitespace (cxx_pp);
          pp_equal (cxx_pp);
@@ -301,7 +303,7 @@ dump_template_bindings (tree parms, tree args, VEC(tree,gc)* typenames)
            pp_string (cxx_pp, M_("<missing>"));
 
          ++arg_idx;
-         need_comma = 1;
+         need_semicolon = true;
        }
 
       parms = TREE_CHAIN (parms);
@@ -313,8 +315,8 @@ dump_template_bindings (tree parms, tree args, VEC(tree,gc)* typenames)
 
   FOR_EACH_VEC_ELT (tree, typenames, i, t)
     {
-      if (need_comma)
-       pp_separate_with_comma (cxx_pp);
+      if (need_semicolon)
+       pp_separate_with_semicolon (cxx_pp);
       dump_type (t, TFF_PLAIN_IDENTIFIER);
       pp_cxx_whitespace (cxx_pp);
       pp_equal (cxx_pp);
@@ -329,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.  */
 
@@ -343,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
@@ -587,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)
@@ -612,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);
@@ -951,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");
@@ -1195,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
     {
@@ -1533,6 +1575,8 @@ dump_function_name (tree t, int flags)
     }
   else if (name && IDENTIFIER_OPNAME_P (name))
     pp_cxx_tree_identifier (cxx_pp, name);
+  else if (name && UDLIT_OPER_P (name))
+    pp_cxx_tree_identifier (cxx_pp, name);
   else
     dump_decl (name, flags);
 
@@ -1748,6 +1792,13 @@ dump_expr (tree t, int flags)
                     | TFF_NO_FUNCTION_ARGUMENTS));
       break;
 
+    case SSA_NAME:
+      if (!DECL_ARTIFICIAL (SSA_NAME_VAR (t)))
+       dump_expr (SSA_NAME_VAR (t), flags);
+      else
+       pp_cxx_ws_string (cxx_pp, M_("<unknown>"));
+      break;
+
     case INTEGER_CST:
     case REAL_CST:
     case STRING_CST:
@@ -1755,6 +1806,10 @@ dump_expr (tree t, int flags)
       pp_constant (cxx_pp, t);
       break;
 
+    case USERDEF_LITERAL:
+      pp_cxx_userdef_literal (cxx_pp, t);
+      break;
+
     case THROW_EXPR:
       /* While waiting for caret diagnostics, avoid printing
         __cxa_allocate_exception, __cxa_throw, and the like.  */
@@ -2051,6 +2106,7 @@ dump_expr (tree t, int flags)
       break;
 
     CASE_CONVERT:
+    case IMPLICIT_CONV_EXPR:
     case VIEW_CONVERT_EXPR:
       {
        tree op = TREE_OPERAND (t, 0);
@@ -2350,6 +2406,7 @@ dump_expr (tree t, int flags)
       break;
 
     case TEMPLATE_TYPE_PARM:
+    case TEMPLATE_TEMPLATE_PARM:
     case BOUND_TEMPLATE_TEMPLATE_PARM:
       dump_type (t, flags);
       break;
@@ -2767,7 +2824,7 @@ static void
 cp_diagnostic_starter (diagnostic_context *context,
                       diagnostic_info *diagnostic)
 {
-  diagnostic_report_current_module (context);
+  diagnostic_report_current_module (context, diagnostic->location);
   cp_print_error_function (context, diagnostic);
   maybe_print_instantiation_context (context);
   maybe_print_constexpr_context (context);
@@ -2777,8 +2834,9 @@ cp_diagnostic_starter (diagnostic_context *context,
 
 static void
 cp_diagnostic_finalizer (diagnostic_context *context,
-                        diagnostic_info *diagnostic ATTRIBUTE_UNUSED)
+                        diagnostic_info *diagnostic)
 {
+  virt_loc_aware_diagnostic_finalizer (context, diagnostic);
   pp_base_destroy_prefix (context->printer);
 }
 
@@ -3196,48 +3254,63 @@ 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");
-       break;  
+                "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++11 or -std=gnu++11");
+        break;
+      case CPP0X_USER_DEFINED_LITERALS:
+       pedwarn (input_location, 0,
+                "user-defined literals "
+                "only available with -std=c++11 or -std=gnu++11");
+       break;
+      case CPP0X_DELEGATING_CTORS:
+       pedwarn (input_location, 0,
+                "delegating constructors "
+                "only available with -std=c++11 or -std=gnu++11");
         break;
       default:
-       gcc_unreachable();
+       gcc_unreachable ();
       }
 }