call.c (build_op_delete_call, [...]): Use Use DECL_SOURCE_LOCATION and "%qD" in infor...
authorPaolo Carlini <paolo.carlini@oracle.com>
Tue, 28 Jul 2015 08:53:57 +0000 (08:53 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 28 Jul 2015 08:53:57 +0000 (08:53 +0000)
2015-07-28  Paolo Carlini  <paolo.carlini@oracle.com>

* call.c (build_op_delete_call, convert_like_real, build_over_call):
Use Use DECL_SOURCE_LOCATION and "%qD" in inform and pedwarn instead
of "%q+D".
* constexpr.c (explain_invalid_constexpr_fn): Likewise.
* decl.c (duplicate_decls): Likewise for warning/warning_at.
* except.c (maybe_noexcept_warning): Likewise.
* friend.c (make_friend_class): Likewise for inform.
* mangle.c (mangle_decl): Likewise for warning/warning_at.
* method.c (process_subob_fn, walk_field_subobs,
maybe_explain_implicit_delete): Likewise for inform.
* parser.c (cp_parser_lambda_introducer): Likewise.
* pt.c (check_specialization_namespace,
maybe_process_partial_specialization): Likewise for permerror.
(redeclare_class_template): Likewise for inform_n.
(coerce_template_parms, tsubst_copy_and_build): Likewise for inform.
* search.c (check_final_overrider): Likewise.
* semantics.c (process_outer_var_ref): Likewise.

From-SVN: r226308

12 files changed:
gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/constexpr.c
gcc/cp/decl.c
gcc/cp/except.c
gcc/cp/friend.c
gcc/cp/mangle.c
gcc/cp/method.c
gcc/cp/parser.c
gcc/cp/pt.c
gcc/cp/search.c
gcc/cp/semantics.c

index 78a6af2e0dc011ff6ad50bd3ac54fccd4fa1e2a0..0fa0926cd5ce60e8d0e558d90ddfff8ee282b871 100644 (file)
@@ -1,3 +1,23 @@
+2015-07-28  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       * call.c (build_op_delete_call, convert_like_real, build_over_call):
+       Use Use DECL_SOURCE_LOCATION and "%qD" in inform and pedwarn instead
+       of "%q+D".
+       * constexpr.c (explain_invalid_constexpr_fn): Likewise.
+       * decl.c (duplicate_decls): Likewise for warning/warning_at.
+       * except.c (maybe_noexcept_warning): Likewise.
+       * friend.c (make_friend_class): Likewise for inform.
+       * mangle.c (mangle_decl): Likewise for warning/warning_at.
+       * method.c (process_subob_fn, walk_field_subobs,
+       maybe_explain_implicit_delete): Likewise for inform.
+       * parser.c (cp_parser_lambda_introducer): Likewise.
+       * pt.c (check_specialization_namespace,
+       maybe_process_partial_specialization): Likewise for permerror.
+       (redeclare_class_template): Likewise for inform_n.
+       (coerce_template_parms, tsubst_copy_and_build): Likewise for inform.
+       * search.c (check_final_overrider): Likewise.
+       * semantics.c (process_outer_var_ref): Likewise.
+
 2015-07-27  Jason Merrill  <jason@redhat.com>
 
        * constexpr.c (cxx_eval_call_expression): Don't add this call to
index 1be2527358a9339a6ac27c0319b0e59f07608b1e..3b0fd692e9fa494a60125391a90c78223f8a57fd 100644 (file)
@@ -5843,7 +5843,7 @@ build_op_delete_call (enum tree_code code, tree addr, tree size,
            = G_("exception cleanup for this placement new selects "
                 "non-placement operator delete");
          const char *msg2
-           = G_("%q+D is a usual (non-placement) deallocation "
+           = G_("%qD is a usual (non-placement) deallocation "
                 "function in C++14 (or with -fsized-deallocation)");
 
          /* But if the class has an operator delete (void *), then that is
@@ -5865,7 +5865,7 @@ build_op_delete_call (enum tree_code code, tree addr, tree size,
            {
              if ((complain & tf_warning)
                  && warning (OPT_Wc__14_compat, msg1))
-               inform (0, msg2, fn);
+               inform (DECL_SOURCE_LOCATION (fn), msg2, fn);
              goto ok;
            }
 
@@ -5875,9 +5875,10 @@ build_op_delete_call (enum tree_code code, tree addr, tree size,
                {
                  /* Only mention C++14 for namespace-scope delete.  */
                  if (DECL_NAMESPACE_SCOPE_P (fn))
-                   inform (0, msg2, fn);
+                   inform (DECL_SOURCE_LOCATION (fn), msg2, fn);
                  else
-                   inform (0, "%q+D is a usual (non-placement) deallocation "
+                   inform (DECL_SOURCE_LOCATION (fn),
+                           "%qD is a usual (non-placement) deallocation "
                            "function", fn);
                }
            }
@@ -6333,8 +6334,8 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
          build_user_type_conversion (totype, convs->u.expr, LOOKUP_NORMAL,
                                      complain);
          if (fn)
-           inform (input_location, "  initializing argument %P of %q+D",
-                   argnum, fn);
+           inform (DECL_SOURCE_LOCATION (fn),
+                   "  initializing argument %P of %qD", argnum, fn);
        }
       return error_mark_node;
 
@@ -6486,8 +6487,8 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
              gcc_unreachable ();
            maybe_print_user_conv_context (convs);
            if (fn)
-             inform (input_location,
-                     "  initializing argument %P of %q+D", argnum, fn);
+             inform (DECL_SOURCE_LOCATION (fn),
+                     "  initializing argument %P of %qD", argnum, fn);
            return error_mark_node;
          }
 
@@ -7307,7 +7308,8 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
              pedwarn (input_location, 0, "deducing %qT as %qT",
                       non_reference (TREE_TYPE (patparm)),
                       non_reference (type));
-             pedwarn (input_location, 0, "  in call to %q+D", cand->fn);
+             pedwarn (DECL_SOURCE_LOCATION (cand->fn), 0,
+                      "  in call to %qD", cand->fn);
              pedwarn (input_location, 0,
                       "  (you can disable this with -fno-deduce-init-list)");
            }
index 2799cb7532857ded9ab245d021cd1a7776e670e7..fc4a3f75a0dfb5dcefd4bcf272ae20ce3176146e 100644 (file)
@@ -829,7 +829,8 @@ explain_invalid_constexpr_fn (tree fun)
 
   save_loc = input_location;
   input_location = DECL_SOURCE_LOCATION (fun);
-  inform (0, "%q+D is not usable as a constexpr function because:", fun);
+  inform (input_location,
+         "%qD is not usable as a constexpr function because:", fun);
   /* First check the declaration.  */
   if (is_valid_constexpr_fn (fun, true))
     {
index b7fe8ef1e7b18ebfc6c4e1a80dc9c8743c10b254..52584c51f1e2f0fcbc91f0bf7ec0792b9a1013d9 100644 (file)
@@ -1378,8 +1378,9 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
          /* If the built-in is not ansi, then programs can override
             it even globally without an error.  */
          else if (! DECL_BUILT_IN (olddecl))
-           warning (0, "library function %q#D redeclared as non-function %q+#D",
-                    olddecl, newdecl);
+           warning_at (DECL_SOURCE_LOCATION (newdecl), 0,
+                       "library function %q#D redeclared as non-function %q#D",
+                       olddecl, newdecl);
          else
            error ("declaration of %q+#D conflicts with built-in "
                   "declaration %q#D", newdecl, olddecl);
index f7409b5c14d7489be79a9f0ce2348034f4be1006..6c366464fbafece07db8aa3f814eb95aa0786f2b 100644 (file)
@@ -1200,8 +1200,9 @@ maybe_noexcept_warning (tree fn)
     {
       warning (OPT_Wnoexcept, "noexcept-expression evaluates to %<false%> "
               "because of a call to %qD", fn);
-      warning (OPT_Wnoexcept, "but %q+D does not throw; perhaps "
-              "it should be declared %<noexcept%>", fn);
+      warning_at (DECL_SOURCE_LOCATION (fn), OPT_Wnoexcept,
+                 "but %qD does not throw; perhaps "
+                 "it should be declared %<noexcept%>", fn);
     }
 }
 
index 14fc5d0b267dbbdbd2bbbf4f5715ec787305026e..e107ceea494390d9df5d6d1b29fbb18732b3bcec 100644 (file)
@@ -329,7 +329,8 @@ make_friend_class (tree type, tree friend_type, bool complain)
                {
                  error ("%qT is not a member class template of %qT",
                         name, ctype);
-                 inform (input_location, "%q+D declared here", decl);
+                 inform (DECL_SOURCE_LOCATION (decl),
+                         "%qD declared here", decl);
                  return;
                }
              if (!template_member_p && (TREE_CODE (decl) != TYPE_DECL
@@ -337,7 +338,8 @@ make_friend_class (tree type, tree friend_type, bool complain)
                {
                  error ("%qT is not a nested class of %qT",
                         name, ctype);
-                 inform (input_location, "%q+D declared here", decl);
+                 inform (DECL_SOURCE_LOCATION (decl),
+                         "%qD declared here", decl);
                  return;
                }
 
index a157b2b776c8d3bd9dec6cb03fcfb8c01e61b0a1..b4d4c0e5c0e770cc45c28bf30ca7bc4c2e810da2 100644 (file)
@@ -3633,15 +3633,17 @@ mangle_decl (const tree decl)
        {
          if (flag_abi_compat_version != 0
              && abi_version_at_least (flag_abi_compat_version))
-           warning (OPT_Wabi, "the mangled name of %q+D changed between "
-                    "-fabi-version=%d (%D) and -fabi-version=%d (%D)",
-                    G.entity, flag_abi_compat_version, id2,
-                    flag_abi_version, id);
+           warning_at (DECL_SOURCE_LOCATION (G.entity), OPT_Wabi,
+                       "the mangled name of %qD changed between "
+                       "-fabi-version=%d (%D) and -fabi-version=%d (%D)",
+                       G.entity, flag_abi_compat_version, id2,
+                       flag_abi_version, id);
          else
-           warning (OPT_Wabi, "the mangled name of %q+D changes between "
-                    "-fabi-version=%d (%D) and -fabi-version=%d (%D)",
-                    G.entity, flag_abi_version, id,
-                    flag_abi_compat_version, id2);
+           warning_at (DECL_SOURCE_LOCATION (G.entity), OPT_Wabi,
+                       "the mangled name of %qD changes between "
+                       "-fabi-version=%d (%D) and -fabi-version=%d (%D)",
+                       G.entity, flag_abi_version, id,
+                       flag_abi_compat_version, id2);
        }
 
       note_mangling_alias (decl, id2);
index 570f800f7c2cbd28494f6637b2509b1847cbb1b8..7d7ec7da187b5b58c331155b072a738df1dc2e38 100644 (file)
@@ -1138,8 +1138,8 @@ process_subob_fn (tree fn, tree *spec_p, bool *trivial_p,
       *constexpr_p = false;
       if (diag)
        {
-         inform (0, "defaulted constructor calls non-constexpr "
-                 "%q+D", fn);
+         inform (DECL_SOURCE_LOCATION (fn),
+                 "defaulted constructor calls non-constexpr %qD", fn);
          explain_invalid_constexpr_fn (fn);
        }
     }
@@ -1199,7 +1199,8 @@ walk_field_subobs (tree fields, tree fnname, special_function_kind sfk,
          if (DECL_INITIAL (field))
            {
              if (diag && DECL_INITIAL (field) == error_mark_node)
-               inform (0, "initializer for %q+#D is invalid", field);
+               inform (DECL_SOURCE_LOCATION (field),
+                       "initializer for %q#D is invalid", field);
              if (trivial_p)
                *trivial_p = false;
              /* Core 1351: If the field has an NSDMI that could throw, the
@@ -1250,8 +1251,9 @@ walk_field_subobs (tree fields, tree fnname, special_function_kind sfk,
            {
              *constexpr_p = false;
              if (diag)
-               inform (0, "defaulted default constructor does not "
-                       "initialize %q+#D", field);
+               inform (DECL_SOURCE_LOCATION (field),
+                       "defaulted default constructor does not "
+                       "initialize %q#D", field);
            }
        }
       else if (sfk == sfk_copy_constructor)
@@ -1615,9 +1617,10 @@ maybe_explain_implicit_delete (tree decl)
               && (type_has_user_declared_move_constructor (ctype)
                   || type_has_user_declared_move_assign (ctype)))
        {
-         inform (0, "%q+#D is implicitly declared as deleted because %qT "
-                "declares a move constructor or move assignment operator",
-                decl, ctype);
+         inform (DECL_SOURCE_LOCATION (decl),
+                 "%q#D is implicitly declared as deleted because %qT "
+                 "declares a move constructor or move assignment operator",
+                 decl, ctype);
          informed = true;
        }
       if (!informed)
@@ -1634,7 +1637,8 @@ maybe_explain_implicit_delete (tree decl)
                                   DECL_INHERITED_CTOR_BASE (decl), parms);
          if (deleted_p)
            {
-             inform (0, "%q+#D is implicitly deleted because the default "
+             inform (DECL_SOURCE_LOCATION (decl),
+                     "%q#D is implicitly deleted because the default "
                      "definition would be ill-formed:", decl);
              synthesized_method_walk (ctype, sfk, const_p,
                                       NULL, NULL, NULL, NULL, true,
index 920cb61ee06d698f08bb68d228ef57bc63b975ef..5642ea2c4aa2eacd5c7824b6746adf2ed3ff1fd8 100644 (file)
@@ -9251,7 +9251,8 @@ cp_parser_lambda_introducer (cp_parser* parser, tree lambda_expr)
              error_at (capture_token->location,
                        "capture of non-variable %qD ",
                        capture_init_expr);
-             inform (0, "%q+#D declared here", capture_init_expr);
+             inform (DECL_SOURCE_LOCATION (capture_init_expr),
+                     "%q#D declared here", capture_init_expr);
              continue;
            }
          if (VAR_P (capture_init_expr)
@@ -9260,7 +9261,8 @@ cp_parser_lambda_introducer (cp_parser* parser, tree lambda_expr)
              if (pedwarn (capture_token->location, 0, "capture of variable "
                           "%qD with non-automatic storage duration",
                           capture_init_expr))
-               inform (0, "%q+#D declared here", capture_init_expr);
+               inform (DECL_SOURCE_LOCATION (capture_init_expr),
+                       "%q#D declared here", capture_init_expr);
              continue;
            }
 
index f15d16fe269606941f98aa2062e874a623100788..e92fefb416d2ae167082109e403daf4c795ed06f 100644 (file)
@@ -793,8 +793,10 @@ check_specialization_namespace (tree tmpl)
     return true;
   else
     {
-      permerror (input_location, "specialization of %qD in different namespace", tmpl);
-      permerror (input_location, "  from definition of %q+#D", tmpl);
+      permerror (input_location,
+                "specialization of %qD in different namespace", tmpl);
+      permerror (DECL_SOURCE_LOCATION (tmpl),
+                "  from definition of %q#D", tmpl);
       return false;
     }
 }
@@ -920,8 +922,10 @@ maybe_process_partial_specialization (tree type)
          if (current_namespace
              != decl_namespace_context (tmpl))
            {
-             permerror (input_location, "specializing %q#T in different namespace", type);
-             permerror (input_location, "  from definition of %q+#D", tmpl);
+             permerror (input_location,
+                        "specializing %q#T in different namespace", type);
+             permerror (DECL_SOURCE_LOCATION (tmpl),
+                        "  from definition of %q#D", tmpl);
            }
 
          /* Check for invalid specialization after instantiation:
@@ -5239,9 +5243,9 @@ redeclare_class_template (tree type, tree parms)
                "redeclared with %d template parameter",
                "redeclared with %d template parameters",
                TREE_VEC_LENGTH (parms));
-      inform_n (input_location, TREE_VEC_LENGTH (tmpl_parms),
-                "previous declaration %q+D used %d template parameter",
-                "previous declaration %q+D used %d template parameters",
+      inform_n (DECL_SOURCE_LOCATION (tmpl), TREE_VEC_LENGTH (tmpl_parms),
+                "previous declaration %qD used %d template parameter",
+                "previous declaration %qD used %d template parameters",
                 tmpl, TREE_VEC_LENGTH (tmpl_parms));
       return false;
     }
@@ -7117,7 +7121,8 @@ coerce_template_parms (tree parms,
                    "(%d, should be %d)", nargs, nparms);
 
          if (in_decl)
-           inform (input_location, "provided for %q+D", in_decl);
+           inform (DECL_SOURCE_LOCATION (in_decl),
+                   "provided for %qD", in_decl);
        }
 
       return error_mark_node;
@@ -15314,7 +15319,8 @@ tsubst_copy_and_build (tree t,
                                      current_class_name, function);
                          }
                        else
-                         inform (0, "%q+D declared here, later in the "
+                         inform (DECL_SOURCE_LOCATION (fn),
+                                 "%qD declared here, later in the "
                                  "translation unit", fn);
                      }
                    function = unq;
index 646ff06a3ef4c08178152f3993e0d57fc28d1331..1176b3e6f4ecef91ad5d86cd9114a7055a6f8621 100644 (file)
@@ -1901,7 +1901,7 @@ check_final_overrider (tree overrider, tree basefn)
          if (pedwarn (DECL_SOURCE_LOCATION (overrider), 0,
                       "invalid covariant return type for %q#D", overrider))
            inform (DECL_SOURCE_LOCATION (basefn),
-                   "  overriding %q+#D", basefn);
+                   "  overriding %q#D", basefn);
        }
       else
        fail = 2;
index 1277c2d6d6c0b3e8a10040babfd2cadfdeec3442..44f9f7acaa36b5457601376adb13f9bf7c5cda79 100644 (file)
@@ -3182,7 +3182,7 @@ process_outer_var_ref (tree decl, tsubst_flags_t complain)
            inform (0, "lambda in local class %q+T cannot "
                    "capture variables from the enclosing context",
                    TYPE_CONTEXT (closure));
-         inform (input_location, "%q+#D declared here", decl);
+         inform (DECL_SOURCE_LOCATION (decl), "%q#D declared here", decl);
        }
       return error_mark_node;
     }
@@ -3192,7 +3192,7 @@ process_outer_var_ref (tree decl, tsubst_flags_t complain)
        error (VAR_P (decl)
               ? G_("use of local variable with automatic storage from containing function")
               : G_("use of parameter from containing function"));
-      inform (input_location, "%q+#D declared here", decl);
+      inform (DECL_SOURCE_LOCATION (decl), "%q#D declared here", decl);
       return error_mark_node;
     }
   return decl;