decl.c (poplevel): Use Use DECL_SOURCE_LOCATION and "%qD" in warning_at instead of...
authorPaolo Carlini <paolo.carlini@oracle.com>
Sun, 26 Jul 2015 09:17:03 +0000 (09:17 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Sun, 26 Jul 2015 09:17:03 +0000 (09:17 +0000)
2015-07-26  Paolo Carlini  <paolo.carlini@oracle.com>

* decl.c (poplevel): Use Use DECL_SOURCE_LOCATION and "%qD"
in warning_at instead of "%q+D" in warning.
(warn_extern_redeclared_static): Likewise for inform.
(check_redeclaration_no_default_args): Likewise for permerror.
(duplicate_decls): Likewise.
(check_previous_goto_1): Likewise for inform.
(check_goto, start_decl, check_for_uninitialized_const_var,
start_preparsed_function, finish_function§): Likewise.
* decl2.c (build_anon_union_vars, c_parse_final_cleanups): Likewise.
* init.c (sort_mem_initializers): Likewise.
* typeck.c (convert_for_initialization): Likewise for inform.
(maybe_warn_about_returning_address_of_local): Likewise.
* typeck2.c (abstract_virtuals_error_sfinae): Likewise for inform.
(cxx_incomplete_type_diagnostic): Likewise for emit_diagnostic.

From-SVN: r226234

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/decl2.c
gcc/cp/init.c
gcc/cp/typeck.c
gcc/cp/typeck2.c

index f7669d3ac07abbc472caeb8614b4fb12d334a2d3..94955195c4ac1263477b07034efba3b69d9f6cce 100644 (file)
@@ -1,3 +1,20 @@
+2015-07-26  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       * decl.c (poplevel): Use Use DECL_SOURCE_LOCATION and "%qD"
+       in warning_at instead of "%q+D" in warning.
+       (warn_extern_redeclared_static): Likewise for inform.
+       (check_redeclaration_no_default_args): Likewise for permerror.
+       (duplicate_decls): Likewise.
+       (check_previous_goto_1): Likewise for inform.
+       (check_goto, start_decl, check_for_uninitialized_const_var,
+       start_preparsed_function, finish_function§): Likewise.
+       * decl2.c (build_anon_union_vars, c_parse_final_cleanups): Likewise.
+       * init.c (sort_mem_initializers): Likewise.
+       * typeck.c (convert_for_initialization): Likewise for inform.
+       (maybe_warn_about_returning_address_of_local): Likewise.
+       * typeck2.c (abstract_virtuals_error_sfinae): Likewise for inform.
+       (cxx_incomplete_type_diagnostic): Likewise for emit_diagnostic.
+
 2015-07-25  Patrick Palka  <ppalka@gcc.gnu.org>
 
        PR c++/66857
index 01b81200596db6161d635b86f31449f1b3f7f1ed..b7fe8ef1e7b18ebfc6c4e1a80dc9c8743c10b254 100644 (file)
@@ -640,14 +640,16 @@ poplevel (int keep, int reverse, int functionbody)
                                     TYPE_ATTRIBUTES (TREE_TYPE (decl)))))
          {
            if (! TREE_USED (decl))
-             warning (OPT_Wunused_variable, "unused variable %q+D", decl);
+             warning_at (DECL_SOURCE_LOCATION (decl),
+                         OPT_Wunused_variable, "unused variable %qD", decl);
            else if (DECL_CONTEXT (decl) == current_function_decl
                     // For -Wunused-but-set-variable leave references alone.
                     && TREE_CODE (TREE_TYPE (decl)) != REFERENCE_TYPE
                     && errorcount == unused_but_set_errorcount)
              {
-               warning (OPT_Wunused_but_set_variable,
-                        "variable %q+D set but not used", decl);
+               warning_at (DECL_SOURCE_LOCATION (decl),
+                           OPT_Wunused_but_set_variable,
+                           "variable %qD set but not used", decl);
                unused_but_set_errorcount = errorcount;
              }
          }
@@ -1157,7 +1159,8 @@ warn_extern_redeclared_static (tree newdecl, tree olddecl)
 
   if (permerror (DECL_SOURCE_LOCATION (newdecl),
                 "%qD was declared %<extern%> and later %<static%>", newdecl))
-    inform (input_location, "previous declaration of %q+D", olddecl);
+    inform (DECL_SOURCE_LOCATION (olddecl),
+           "previous declaration of %qD", olddecl);
 }
 
 /* NEW_DECL is a redeclaration of OLD_DECL; both are functions or
@@ -1254,8 +1257,8 @@ check_redeclaration_no_default_args (tree decl)
        t && t != void_list_node; t = TREE_CHAIN (t))
     if (TREE_PURPOSE (t))
       {
-       permerror (input_location,
-                  "redeclaration of %q+#D may not have default "
+       permerror (DECL_SOURCE_LOCATION (decl),
+                  "redeclaration of %q#D may not have default "
                   "arguments", decl);
        return;
       }
@@ -1328,8 +1331,9 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
               && DECL_UNINLINABLE (olddecl)
               && lookup_attribute ("noinline", DECL_ATTRIBUTES (olddecl)))
        {
-         if (warning (OPT_Wattributes, "function %q+D redeclared as inline",
-                      newdecl))
+         if (warning_at (DECL_SOURCE_LOCATION (newdecl),
+                         OPT_Wattributes, "function %qD redeclared as inline",
+                         newdecl))
            inform (DECL_SOURCE_LOCATION (olddecl),
                    "previous declaration of %qD with attribute noinline",
                    olddecl);
@@ -1338,8 +1342,9 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
               && DECL_UNINLINABLE (newdecl)
               && lookup_attribute ("noinline", DECL_ATTRIBUTES (newdecl)))
        {
-         if (warning (OPT_Wattributes, "function %q+D redeclared with "
-                      "attribute noinline", newdecl))
+         if (warning_at (DECL_SOURCE_LOCATION (newdecl),
+                         OPT_Wattributes, "function %qD redeclared with "
+                         "attribute noinline", newdecl))
            inform (DECL_SOURCE_LOCATION (olddecl),
                    "previous declaration of %qD was inline",
                    olddecl);
@@ -1436,8 +1441,9 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
              /* A near match; override the builtin.  */
 
              if (TREE_PUBLIC (newdecl))
-               warning (0, "new declaration %q+#D ambiguates built-in "
-                        "declaration %q#D", newdecl, olddecl);
+               warning_at (DECL_SOURCE_LOCATION (newdecl), 0,
+                           "new declaration %q#D ambiguates built-in "
+                           "declaration %q#D", newdecl, olddecl);
              else
                warning (OPT_Wshadow, 
                          DECL_BUILT_IN (olddecl)
@@ -1665,10 +1671,10 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
        {
          error_at (DECL_SOURCE_LOCATION (newdecl), errmsg, newdecl);
          if (DECL_NAME (olddecl) != NULL_TREE)
-           inform (input_location,
+           inform (DECL_SOURCE_LOCATION (olddecl),
                    (DECL_INITIAL (olddecl) && namespace_bindings_p ())
-                   ? G_("%q+#D previously defined here")
-                   : G_("%q+#D previously declared here"), olddecl);
+                   ? G_("%q#D previously defined here")
+                   : G_("%q#D previously declared here"), olddecl);
          return error_mark_node;
        }
       else if (TREE_CODE (olddecl) == FUNCTION_DECL
@@ -1678,7 +1684,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
        {
          /* Prototype decl follows defn w/o prototype.  */
          if (warning_at (DECL_SOURCE_LOCATION (newdecl), 0,
-                         "prototype specified for %q+#D", newdecl))
+                         "prototype specified for %q#D", newdecl))
            inform (DECL_SOURCE_LOCATION (olddecl),
                    "previous non-prototype definition here");
        }
@@ -1831,9 +1837,10 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
          && (! DECL_TEMPLATE_SPECIALIZATION (newdecl)
              || DECL_TEMPLATE_SPECIALIZATION (olddecl)))
        {
-         if (warning (OPT_Wredundant_decls,
-                      "redundant redeclaration of %q+D in same scope",
-                      newdecl))
+         if (warning_at (DECL_SOURCE_LOCATION (newdecl),
+                         OPT_Wredundant_decls,
+                         "redundant redeclaration of %qD in same scope",
+                         newdecl))
            inform (DECL_SOURCE_LOCATION (olddecl),
                    "previous declaration of %qD", olddecl);
        }
@@ -2946,10 +2953,11 @@ check_previous_goto_1 (tree decl, cp_binding_level* level, tree names,
          if (complained)
            {
              if (problem > 1)
-               inform (input_location,
-                       "  crosses initialization of %q+#D", new_decls);
+               inform (DECL_SOURCE_LOCATION (new_decls),
+                       "  crosses initialization of %q#D", new_decls);
              else
-               inform (input_location, "  enters scope of %q+#D which has "
+               inform (DECL_SOURCE_LOCATION (new_decls),
+                       "  enters scope of %q#D which has "
                        "non-trivial destructor", new_decls);
            }
        }
@@ -3052,7 +3060,8 @@ check_goto (tree decl)
   if (ent->in_try_scope || ent->in_catch_scope
       || ent->in_omp_scope || !vec_safe_is_empty (ent->bad_decls))
     {
-      complained = permerror (input_location, "jump to label %q+D", decl);
+      complained = permerror (DECL_SOURCE_LOCATION (decl),
+                             "jump to label %qD", decl);
       if (complained)
        inform (input_location, "  from here");
       identified = true;
@@ -3072,9 +3081,11 @@ check_goto (tree decl)
       else if (complained)
        {
          if (u > 1)
-           inform (input_location, "  skips initialization of %q+#D", bad);
+           inform (DECL_SOURCE_LOCATION (bad),
+                   "  skips initialization of %q#D", bad);
          else
-           inform (input_location, "  enters scope of %q+#D which has "
+           inform (DECL_SOURCE_LOCATION (bad),
+                   "  enters scope of %q#D which has "
                    "non-trivial destructor", bad);
        }
     }
@@ -3103,8 +3114,8 @@ check_goto (tree decl)
            {
              if (!identified)
                {
-                 complained = permerror (input_location,
-                                         "jump to label %q+D", decl);
+                 complained = permerror (DECL_SOURCE_LOCATION (decl),
+                                         "jump to label %qD", decl);
                  if (complained)
                    inform (input_location, "  from here");
                  identified = true;
@@ -4738,7 +4749,8 @@ start_decl (const cp_declarator *declarator,
       && DECL_DECLARED_INLINE_P (decl)
       && DECL_UNINLINABLE (decl)
       && lookup_attribute ("noinline", DECL_ATTRIBUTES (decl)))
-    warning (0, "inline function %q+D given attribute noinline", decl);
+    warning_at (DECL_SOURCE_LOCATION (decl), 0,
+               "inline function %qD given attribute noinline", decl);
 
   if (TYPE_P (context) && COMPLETE_TYPE_P (complete_type (context)))
     {
@@ -5291,8 +5303,9 @@ check_for_uninitialized_const_var (tree decl)
            inform (DECL_SOURCE_LOCATION (defaulted_ctor),
                    "constructor is not user-provided because it is "
                    "explicitly defaulted in the class body");
-         inform (0, "and the implicitly-defined constructor does not "
-                 "initialize %q+#D", field);
+         inform (DECL_SOURCE_LOCATION (field),
+                 "and the implicitly-defined constructor does not "
+                 "initialize %q#D", field);
        }
     }
 }
@@ -13375,7 +13388,8 @@ start_preparsed_function (tree decl1, tree attrs, int flags)
 
   if (DECL_DECLARED_INLINE_P (decl1)
       && lookup_attribute ("noinline", attrs))
-    warning (0, "inline function %q+D given attribute noinline", decl1);
+    warning_at (DECL_SOURCE_LOCATION (decl1), 0,
+               "inline function %qD given attribute noinline", decl1);
 
   /* Handle gnu_inline attribute.  */
   if (GNU_INLINE_P (decl1))
@@ -13516,8 +13530,9 @@ start_preparsed_function (tree decl1, tree attrs, int flags)
                    }
 
                  if (context == NULL)
-                   warning (OPT_Wmissing_declarations,
-                            "no previous declaration for %q+D", decl1);
+                   warning_at (DECL_SOURCE_LOCATION (decl1),
+                               OPT_Wmissing_declarations,
+                               "no previous declaration for %qD", decl1);
                }
 
              decl1 = olddecl;
@@ -14327,8 +14342,9 @@ finish_function (int flags)
            && TREE_CODE (TREE_TYPE (decl)) != REFERENCE_TYPE
            && (!CLASS_TYPE_P (TREE_TYPE (decl))
                || !TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (decl))))
-         warning (OPT_Wunused_but_set_parameter,
-                  "parameter %q+D set but not used", decl);
+         warning_at (DECL_SOURCE_LOCATION (decl),
+                     OPT_Wunused_but_set_parameter,
+                     "parameter %qD set but not used", decl);
       unused_but_set_errorcount = errorcount;
     }
 
index cac0508f881af2e0cd21a135b6d594787d30b328..a45755ec8def91a08f779462d2f1a058b15143d9 100644 (file)
@@ -1531,15 +1531,18 @@ build_anon_union_vars (tree type, tree object)
        continue;
       if (TREE_CODE (field) != FIELD_DECL)
        {
-         permerror (input_location, "%q+#D invalid; an anonymous union can only "
+         permerror (DECL_SOURCE_LOCATION (field),
+                    "%q#D invalid; an anonymous union can only "
                     "have non-static data members", field);
          continue;
        }
 
       if (TREE_PRIVATE (field))
-       permerror (input_location, "private member %q+#D in anonymous union", field);
+       permerror (DECL_SOURCE_LOCATION (field),
+                  "private member %q#D in anonymous union", field);
       else if (TREE_PROTECTED (field))
-       permerror (input_location, "protected member %q+#D in anonymous union", field);
+       permerror (DECL_SOURCE_LOCATION (field),
+                  "protected member %q#D in anonymous union", field);
 
       if (processing_template_decl)
        ref = build_min_nt_loc (UNKNOWN_LOCATION, COMPONENT_REF, object,
@@ -4764,7 +4767,8 @@ c_parse_final_cleanups (void)
               && DECL_INITIAL (DECL_TEMPLATE_RESULT
                                (template_for_substitution (decl)))))
        {
-         warning (0, "inline function %q+D used but never defined", decl);
+         warning_at (DECL_SOURCE_LOCATION (decl), 0,
+                     "inline function %qD used but never defined", decl);
          /* Avoid a duplicate warning from check_global_declaration.  */
          TREE_NO_WARNING (decl) = 1;
        }
index dbbe7d5d02bf0812fccf568d7cda87999f4cd3d7..1ed8f6c625e38f6dc51438b218a75d7bc4041cbb 100644 (file)
@@ -936,13 +936,15 @@ sort_mem_initializers (tree t, tree mem_inits)
       if (warn_reorder && !subobject_init)
        {
          if (TREE_CODE (TREE_PURPOSE (next_subobject)) == FIELD_DECL)
-           warning (OPT_Wreorder, "%q+D will be initialized after",
-                    TREE_PURPOSE (next_subobject));
+           warning_at (DECL_SOURCE_LOCATION (TREE_PURPOSE (next_subobject)),
+                       OPT_Wreorder, "%qD will be initialized after",
+                       TREE_PURPOSE (next_subobject));
          else
            warning (OPT_Wreorder, "base %qT will be initialized after",
                     TREE_PURPOSE (next_subobject));
          if (TREE_CODE (subobject) == FIELD_DECL)
-           warning (OPT_Wreorder, "  %q+#D", subobject);
+           warning_at (DECL_SOURCE_LOCATION (subobject),
+                       OPT_Wreorder, "  %q#D", subobject);
          else
            warning (OPT_Wreorder, "  base %qT", subobject);
          warning_at (DECL_SOURCE_LOCATION (current_function_decl),
index b88a3fd42cff716fd2af3c24095252d7933bb85a..86cf0866ce138a5df1fe84b41081c8de8ee25af6 100644 (file)
@@ -8368,8 +8368,8 @@ convert_for_initialization (tree exp, tree type, tree rhs, int flags,
 
       if (fndecl
          && (warningcount + werrorcount > savew || errorcount > savee))
-       inform (input_location,
-               "in passing argument %P of %q+D", parmnum, fndecl);
+       inform (DECL_SOURCE_LOCATION (fndecl),
+               "in passing argument %P of %qD", parmnum, fndecl);
 
       return rhs;
     }
@@ -8448,14 +8448,18 @@ maybe_warn_about_returning_address_of_local (tree retval)
           || TREE_PUBLIC (whats_returned)))
     {
       if (TREE_CODE (valtype) == REFERENCE_TYPE)
-       warning (OPT_Wreturn_local_addr, "reference to local variable %q+D returned",
-                whats_returned);
+       warning_at (DECL_SOURCE_LOCATION (whats_returned),
+                   OPT_Wreturn_local_addr,
+                   "reference to local variable %qD returned",
+                   whats_returned);
       else if (TREE_CODE (whats_returned) == LABEL_DECL)
-       warning (OPT_Wreturn_local_addr, "address of label %q+D returned",
-                whats_returned);
+       warning_at (DECL_SOURCE_LOCATION (whats_returned),
+                   OPT_Wreturn_local_addr, "address of label %qD returned",
+                   whats_returned);
       else
-       warning (OPT_Wreturn_local_addr, "address of local variable %q+D "
-                "returned", whats_returned);
+       warning_at (DECL_SOURCE_LOCATION (whats_returned),
+                   OPT_Wreturn_local_addr, "address of local variable %qD "
+                   "returned", whats_returned);
       return true;
     }
 
index eb51784f2cf0ddf0e642b93c2ddf72698ef659fc..8a3a53720a4257e97d47c0c143ace7c022530caf 100644 (file)
@@ -389,7 +389,7 @@ abstract_virtuals_error_sfinae (tree decl, tree type, abstract_class_use use,
       FOR_EACH_VEC_ELT (*pure, ix, fn)
        if (! DECL_CLONED_FUNCTION_P (fn)
            || DECL_COMPLETE_DESTRUCTOR_P (fn))
-         inform (input_location, "\t%+#D", fn);
+         inform (DECL_SOURCE_LOCATION (fn), "\t%#D", fn);
 
       /* Now truncate the vector.  This leaves it non-null, so we know
         there are pure virtuals, but empty so we don't list them out
@@ -473,8 +473,8 @@ cxx_incomplete_type_diagnostic (const_tree value, const_tree type,
                     || TREE_CODE (value) == PARM_DECL
                     || TREE_CODE (value) == FIELD_DECL))
     {
-      complained = emit_diagnostic (diag_kind, input_location, 0,
-                                   "%q+D has incomplete type", value);
+      complained = emit_diagnostic (diag_kind, DECL_SOURCE_LOCATION (value), 0,
+                                   "%qD has incomplete type", value);
       is_decl = true;
     } 
  retry: