Commit 9a977ce3 by Paolo Carlini Committed by Paolo Carlini

decl.c (duplicate_decls): Consistently use DECL_SOURCE_LOCATION in errors about…

decl.c (duplicate_decls): Consistently use DECL_SOURCE_LOCATION in errors about redefined default...

2018-06-18  Paolo Carlini  <paolo.carlini@oracle.com>

	* decl.c (duplicate_decls): Consistently use DECL_SOURCE_LOCATION
	in errors about redefined default arguments; tidy.

From-SVN: r261702
parent 5f9bda14
2018-06-18 Paolo Carlini <paolo.carlini@oracle.com>
* decl.c (duplicate_decls): Consistently use DECL_SOURCE_LOCATION
in errors about redefined default arguments; tidy.
2018-06-16 Kugan Vivekanandarajah <kuganv@linaro.org> 2018-06-16 Kugan Vivekanandarajah <kuganv@linaro.org>
* constexpr.c (potential_constant_expression_1): Handle ABSU_EXPR. * constexpr.c (potential_constant_expression_1): Handle ABSU_EXPR.
......
...@@ -1319,6 +1319,8 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) ...@@ -1319,6 +1319,8 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
int olddecl_friend = 0, types_match = 0, hidden_friend = 0; int olddecl_friend = 0, types_match = 0, hidden_friend = 0;
int new_defines_function = 0; int new_defines_function = 0;
tree new_template_info; tree new_template_info;
location_t olddecl_loc = DECL_SOURCE_LOCATION (olddecl);
location_t newdecl_loc = DECL_SOURCE_LOCATION (newdecl);
if (newdecl == olddecl) if (newdecl == olddecl)
return olddecl; return olddecl;
...@@ -1342,13 +1344,15 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) ...@@ -1342,13 +1344,15 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
if (TREE_CODE (newdecl) == TEMPLATE_DECL if (TREE_CODE (newdecl) == TEMPLATE_DECL
&& TREE_CODE (olddecl) != TEMPLATE_DECL && TREE_CODE (olddecl) != TEMPLATE_DECL
&& check_raw_literal_operator (olddecl)) && check_raw_literal_operator (olddecl))
error ("literal operator template %q+D conflicts with" error_at (newdecl_loc,
" raw literal operator %qD", newdecl, olddecl); "literal operator template %qD conflicts with"
" raw literal operator %qD", newdecl, olddecl);
else if (TREE_CODE (newdecl) != TEMPLATE_DECL else if (TREE_CODE (newdecl) != TEMPLATE_DECL
&& TREE_CODE (olddecl) == TEMPLATE_DECL && TREE_CODE (olddecl) == TEMPLATE_DECL
&& check_raw_literal_operator (newdecl)) && check_raw_literal_operator (newdecl))
error ("raw literal operator %q+D conflicts with" error_at (newdecl_loc,
" literal operator template %qD", newdecl, olddecl); "raw literal operator %qD conflicts with"
" literal operator template %qD", newdecl, olddecl);
} }
/* True to merge attributes between the declarations, false to /* True to merge attributes between the declarations, false to
...@@ -1366,10 +1370,10 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) ...@@ -1366,10 +1370,10 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
&& diagnose_mismatched_attributes (olddecl, newdecl)) && diagnose_mismatched_attributes (olddecl, newdecl))
{ {
if (DECL_INITIAL (olddecl)) if (DECL_INITIAL (olddecl))
inform (DECL_SOURCE_LOCATION (olddecl), inform (olddecl_loc,
"previous definition of %qD was here", olddecl); "previous definition of %qD was here", olddecl);
else else
inform (DECL_SOURCE_LOCATION (olddecl), inform (olddecl_loc,
"previous declaration of %qD was here", olddecl); "previous declaration of %qD was here", olddecl);
} }
...@@ -1386,7 +1390,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) ...@@ -1386,7 +1390,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
{ {
if (TREE_PUBLIC (newdecl) if (TREE_PUBLIC (newdecl)
&& CP_DECL_CONTEXT (newdecl) == global_namespace) && CP_DECL_CONTEXT (newdecl) == global_namespace)
warning_at (DECL_SOURCE_LOCATION (newdecl), warning_at (newdecl_loc,
OPT_Wbuiltin_declaration_mismatch, OPT_Wbuiltin_declaration_mismatch,
"built-in function %qD declared as non-function", "built-in function %qD declared as non-function",
newdecl); newdecl);
...@@ -1398,7 +1402,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) ...@@ -1398,7 +1402,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
bad choice of name. */ bad choice of name. */
if (! TREE_PUBLIC (newdecl)) if (! TREE_PUBLIC (newdecl))
{ {
warning_at (DECL_SOURCE_LOCATION (newdecl), warning_at (newdecl_loc,
OPT_Wshadow, OPT_Wshadow,
DECL_BUILT_IN (olddecl) DECL_BUILT_IN (olddecl)
? G_("shadowing built-in function %q#D") ? G_("shadowing built-in function %q#D")
...@@ -1409,20 +1413,21 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) ...@@ -1409,20 +1413,21 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
/* If the built-in is not ansi, then programs can override /* If the built-in is not ansi, then programs can override
it even globally without an error. */ it even globally without an error. */
else if (! DECL_BUILT_IN (olddecl)) else if (! DECL_BUILT_IN (olddecl))
warning_at (DECL_SOURCE_LOCATION (newdecl), 0, warning_at (newdecl_loc, 0,
"library function %q#D redeclared as non-function %q#D", "library function %q#D redeclared as non-function %q#D",
olddecl, newdecl); olddecl, newdecl);
else else
error ("declaration of %q+#D conflicts with built-in " error_at (newdecl_loc,
"declaration %q#D", newdecl, olddecl); "declaration of %q#D conflicts with built-in "
"declaration %q#D", newdecl, olddecl);
return NULL_TREE; return NULL_TREE;
} }
else if (DECL_OMP_DECLARE_REDUCTION_P (olddecl)) else if (DECL_OMP_DECLARE_REDUCTION_P (olddecl))
{ {
gcc_assert (DECL_OMP_DECLARE_REDUCTION_P (newdecl)); gcc_assert (DECL_OMP_DECLARE_REDUCTION_P (newdecl));
error_at (DECL_SOURCE_LOCATION (newdecl), error_at (newdecl_loc,
"redeclaration of %<pragma omp declare reduction%>"); "redeclaration of %<pragma omp declare reduction%>");
inform (DECL_SOURCE_LOCATION (olddecl), inform (olddecl_loc,
"previous %<pragma omp declare reduction%> declaration"); "previous %<pragma omp declare reduction%> declaration");
return error_mark_node; return error_mark_node;
} }
...@@ -1481,7 +1486,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) ...@@ -1481,7 +1486,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
next_arg:; next_arg:;
} }
warning_at (DECL_SOURCE_LOCATION (newdecl), warning_at (newdecl_loc,
OPT_Wbuiltin_declaration_mismatch, OPT_Wbuiltin_declaration_mismatch,
"declaration of %q#D conflicts with built-in " "declaration of %q#D conflicts with built-in "
"declaration %q#D", newdecl, olddecl); "declaration %q#D", newdecl, olddecl);
...@@ -1510,16 +1515,16 @@ next_arg:; ...@@ -1510,16 +1515,16 @@ next_arg:;
{ {
if (DECL_INITIAL (newdecl)) if (DECL_INITIAL (newdecl))
{ {
error_at (DECL_SOURCE_LOCATION (newdecl), error_at (newdecl_loc,
"definition of %q#D ambiguates built-in " "definition of %q#D ambiguates built-in "
"declaration %q#D", newdecl, olddecl); "declaration %q#D", newdecl, olddecl);
return error_mark_node; return error_mark_node;
} }
if (permerror (DECL_SOURCE_LOCATION (newdecl), if (permerror (newdecl_loc,
"new declaration %q#D ambiguates built-in" "new declaration %q#D ambiguates built-in"
" declaration %q#D", newdecl, olddecl) " declaration %q#D", newdecl, olddecl)
&& flag_permissive) && flag_permissive)
inform (DECL_SOURCE_LOCATION (newdecl), inform (newdecl_loc,
"ignoring the %q#D declaration", newdecl); "ignoring the %q#D declaration", newdecl);
return flag_permissive ? olddecl : error_mark_node; return flag_permissive ? olddecl : error_mark_node;
} }
...@@ -1528,7 +1533,7 @@ next_arg:; ...@@ -1528,7 +1533,7 @@ next_arg:;
/* A near match; override the builtin. */ /* A near match; override the builtin. */
if (TREE_PUBLIC (newdecl)) if (TREE_PUBLIC (newdecl))
warning_at (DECL_SOURCE_LOCATION (newdecl), warning_at (newdecl_loc,
OPT_Wbuiltin_declaration_mismatch, OPT_Wbuiltin_declaration_mismatch,
"new declaration %q#D ambiguates built-in " "new declaration %q#D ambiguates built-in "
"declaration %q#D", newdecl, olddecl); "declaration %q#D", newdecl, olddecl);
...@@ -1624,7 +1629,7 @@ next_arg:; ...@@ -1624,7 +1629,7 @@ next_arg:;
error ("%q#D redeclared as different kind of symbol", newdecl); error ("%q#D redeclared as different kind of symbol", newdecl);
if (TREE_CODE (olddecl) == TREE_LIST) if (TREE_CODE (olddecl) == TREE_LIST)
olddecl = TREE_VALUE (olddecl); olddecl = TREE_VALUE (olddecl);
inform (DECL_SOURCE_LOCATION (olddecl), inform (olddecl_loc,
"previous declaration %q#D", olddecl); "previous declaration %q#D", olddecl);
return error_mark_node; return error_mark_node;
...@@ -1644,8 +1649,9 @@ next_arg:; ...@@ -1644,8 +1649,9 @@ next_arg:;
if (TREE_CODE (DECL_TEMPLATE_RESULT (olddecl)) == TYPE_DECL if (TREE_CODE (DECL_TEMPLATE_RESULT (olddecl)) == TYPE_DECL
|| TREE_CODE (DECL_TEMPLATE_RESULT (newdecl)) == TYPE_DECL) || TREE_CODE (DECL_TEMPLATE_RESULT (newdecl)) == TYPE_DECL)
{ {
error ("conflicting declaration of template %q+#D", newdecl); error_at (newdecl_loc,
inform (DECL_SOURCE_LOCATION (olddecl), "conflicting declaration of template %q#D", newdecl);
inform (olddecl_loc,
"previous declaration %q#D", olddecl); "previous declaration %q#D", olddecl);
return error_mark_node; return error_mark_node;
} }
...@@ -1663,8 +1669,9 @@ next_arg:; ...@@ -1663,8 +1669,9 @@ next_arg:;
// constraints. // constraints.
&& equivalently_constrained (olddecl, newdecl)) && equivalently_constrained (olddecl, newdecl))
{ {
error ("ambiguating new declaration %q+#D", newdecl); error_at (newdecl_loc, "ambiguating new declaration %q#D",
inform (DECL_SOURCE_LOCATION (olddecl), newdecl);
inform (olddecl_loc,
"old declaration %q#D", olddecl); "old declaration %q#D", olddecl);
} }
else if (check_concept_refinement (olddecl, newdecl)) else if (check_concept_refinement (olddecl, newdecl))
...@@ -1675,9 +1682,10 @@ next_arg:; ...@@ -1675,9 +1682,10 @@ next_arg:;
{ {
if (DECL_EXTERN_C_P (newdecl) && DECL_EXTERN_C_P (olddecl)) if (DECL_EXTERN_C_P (newdecl) && DECL_EXTERN_C_P (olddecl))
{ {
error ("conflicting declaration of C function %q+#D", error_at (newdecl_loc,
newdecl); "conflicting declaration of C function %q#D",
inform (DECL_SOURCE_LOCATION (olddecl), newdecl);
inform (olddecl_loc,
"previous declaration %q#D", olddecl); "previous declaration %q#D", olddecl);
return NULL_TREE; return NULL_TREE;
} }
...@@ -1691,8 +1699,9 @@ next_arg:; ...@@ -1691,8 +1699,9 @@ next_arg:;
// And the same constraints. // And the same constraints.
&& equivalently_constrained (newdecl, olddecl)) && equivalently_constrained (newdecl, olddecl))
{ {
error ("ambiguating new declaration of %q+#D", newdecl); error_at (newdecl_loc,
inform (DECL_SOURCE_LOCATION (olddecl), "ambiguating new declaration of %q#D", newdecl);
inform (olddecl_loc,
"old declaration %q#D", olddecl); "old declaration %q#D", olddecl);
return error_mark_node; return error_mark_node;
} }
...@@ -1701,8 +1710,8 @@ next_arg:; ...@@ -1701,8 +1710,8 @@ next_arg:;
} }
else else
{ {
error ("conflicting declaration %q+#D", newdecl); error_at (newdecl_loc, "conflicting declaration %q#D", newdecl);
inform (DECL_SOURCE_LOCATION (olddecl), inform (olddecl_loc,
"previous declaration as %q#D", olddecl); "previous declaration as %q#D", olddecl);
return error_mark_node; return error_mark_node;
} }
...@@ -1757,9 +1766,9 @@ next_arg:; ...@@ -1757,9 +1766,9 @@ next_arg:;
const char *errmsg = redeclaration_error_message (newdecl, olddecl); const char *errmsg = redeclaration_error_message (newdecl, olddecl);
if (errmsg) if (errmsg)
{ {
error_at (DECL_SOURCE_LOCATION (newdecl), errmsg, newdecl); error_at (newdecl_loc, errmsg, newdecl);
if (DECL_NAME (olddecl) != NULL_TREE) if (DECL_NAME (olddecl) != NULL_TREE)
inform (DECL_SOURCE_LOCATION (olddecl), inform (olddecl_loc,
(DECL_INITIAL (olddecl) && namespace_bindings_p ()) (DECL_INITIAL (olddecl) && namespace_bindings_p ())
? G_("%q#D previously defined here") ? G_("%q#D previously defined here")
: G_("%q#D previously declared here"), olddecl); : G_("%q#D previously declared here"), olddecl);
...@@ -1771,9 +1780,9 @@ next_arg:; ...@@ -1771,9 +1780,9 @@ next_arg:;
&& prototype_p (TREE_TYPE (newdecl))) && prototype_p (TREE_TYPE (newdecl)))
{ {
/* Prototype decl follows defn w/o prototype. */ /* Prototype decl follows defn w/o prototype. */
if (warning_at (DECL_SOURCE_LOCATION (newdecl), 0, if (warning_at (newdecl_loc, 0,
"prototype specified for %q#D", newdecl)) "prototype specified for %q#D", newdecl))
inform (DECL_SOURCE_LOCATION (olddecl), inform (olddecl_loc,
"previous non-prototype definition here"); "previous non-prototype definition here");
} }
else if (VAR_OR_FUNCTION_DECL_P (olddecl) else if (VAR_OR_FUNCTION_DECL_P (olddecl)
...@@ -1812,9 +1821,10 @@ next_arg:; ...@@ -1812,9 +1821,10 @@ next_arg:;
} }
else else
{ {
error ("conflicting declaration of %q+#D with %qL linkage", error_at (newdecl_loc,
newdecl, DECL_LANGUAGE (newdecl)); "conflicting declaration of %q#D with %qL linkage",
inform (DECL_SOURCE_LOCATION (olddecl), newdecl, DECL_LANGUAGE (newdecl));
inform (olddecl_loc,
"previous declaration with %qL linkage", "previous declaration with %qL linkage",
DECL_LANGUAGE (olddecl)); DECL_LANGUAGE (olddecl));
} }
...@@ -1848,18 +1858,19 @@ next_arg:; ...@@ -1848,18 +1858,19 @@ next_arg:;
if (simple_cst_equal (TREE_PURPOSE (t1), if (simple_cst_equal (TREE_PURPOSE (t1),
TREE_PURPOSE (t2)) == 1) TREE_PURPOSE (t2)) == 1)
{ {
if (permerror (input_location, if (permerror (newdecl_loc,
"default argument given for parameter " "default argument given for parameter "
"%d of %q#D", i, newdecl)) "%d of %q#D", i, newdecl))
inform (DECL_SOURCE_LOCATION (olddecl), inform (olddecl_loc,
"previous specification in %q#D here", "previous specification in %q#D here",
olddecl); olddecl);
} }
else else
{ {
error ("default argument given for parameter %d " error_at (newdecl_loc,
"of %q#D", i, newdecl); "default argument given for parameter %d "
inform (DECL_SOURCE_LOCATION (olddecl), "of %q#D", i, newdecl);
inform (olddecl_loc,
"previous specification in %q#D here", "previous specification in %q#D here",
olddecl); olddecl);
} }
...@@ -1924,11 +1935,11 @@ next_arg:; ...@@ -1924,11 +1935,11 @@ next_arg:;
&& (! DECL_TEMPLATE_SPECIALIZATION (newdecl) && (! DECL_TEMPLATE_SPECIALIZATION (newdecl)
|| DECL_TEMPLATE_SPECIALIZATION (olddecl))) || DECL_TEMPLATE_SPECIALIZATION (olddecl)))
{ {
if (warning_at (DECL_SOURCE_LOCATION (newdecl), if (warning_at (newdecl_loc,
OPT_Wredundant_decls, OPT_Wredundant_decls,
"redundant redeclaration of %qD in same scope", "redundant redeclaration of %qD in same scope",
newdecl)) newdecl))
inform (DECL_SOURCE_LOCATION (olddecl), inform (olddecl_loc,
"previous declaration of %qD", olddecl); "previous declaration of %qD", olddecl);
} }
...@@ -1937,8 +1948,8 @@ next_arg:; ...@@ -1937,8 +1948,8 @@ next_arg:;
{ {
if (DECL_DELETED_FN (newdecl)) if (DECL_DELETED_FN (newdecl))
{ {
error ("deleted definition of %q+D", newdecl); error_at (newdecl_loc, "deleted definition of %qD", newdecl);
inform (DECL_SOURCE_LOCATION (olddecl), inform (olddecl_loc,
"previous declaration of %qD", olddecl); "previous declaration of %qD", olddecl);
} }
DECL_DELETED_FN (newdecl) |= DECL_DELETED_FN (olddecl); DECL_DELETED_FN (newdecl) |= DECL_DELETED_FN (olddecl);
...@@ -2507,10 +2518,10 @@ next_arg:; ...@@ -2507,10 +2518,10 @@ next_arg:;
&& DECL_VISIBILITY_SPECIFIED (newdecl) && DECL_VISIBILITY_SPECIFIED (newdecl)
&& DECL_VISIBILITY (newdecl) != DECL_VISIBILITY (olddecl)) && DECL_VISIBILITY (newdecl) != DECL_VISIBILITY (olddecl))
{ {
if (warning_at (DECL_SOURCE_LOCATION (newdecl), OPT_Wattributes, if (warning_at (newdecl_loc, OPT_Wattributes,
"%qD: visibility attribute ignored because it " "%qD: visibility attribute ignored because it "
"conflicts with previous declaration", newdecl)) "conflicts with previous declaration", newdecl))
inform (DECL_SOURCE_LOCATION (olddecl), inform (olddecl_loc,
"previous declaration of %qD", olddecl); "previous declaration of %qD", olddecl);
} }
/* Choose the declaration which specified visibility. */ /* Choose the declaration which specified visibility. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment