call.c (build_op_delete_call, [...]): Use Use DECL_SOURCE_LOCATION and "%qD" in inform and pedwarn instead of "%q+D".

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
This commit is contained in:
Paolo Carlini 2015-07-28 08:53:57 +00:00 committed by Paolo Carlini
parent f87a37c689
commit 4b1cbcee3e
12 changed files with 88 additions and 47 deletions

View 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

View 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)");
}

View 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))
{

View 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);

View 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);
}
}

View 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;
}

View 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);

View 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,

View 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;
}

View 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;

View 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;

View 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;