Commit f4252989 by Jason Merrill Committed by Jason Merrill

decl.c (warn_extern_redeclared_static): Use the location of newdecl in…

decl.c (warn_extern_redeclared_static): Use the location of newdecl in diagnostics, not input_location.

	* decl.c (warn_extern_redeclared_static): Use the location of
	newdecl in diagnostics, not input_location.
	(validate_constexpr_redeclaration): Likewise.
	(check_redeclaration_no_default_args): Likewise.
	(duplicate_decls): Likewise.
	(check_redeclaration_exception_specification): Likewise.
	Change second diagnostic to inform.

From-SVN: r223777
parent 929614bf
2015-05-27 Jason Merrill <jason@redhat.com>
* decl.c (warn_extern_redeclared_static): Use the location of
newdecl in diagnostics, not input_location.
(validate_constexpr_redeclaration): Likewise.
(check_redeclaration_no_default_args): Likewise.
(duplicate_decls): Likewise.
(check_redeclaration_exception_specification): Likewise.
Change second diagnostic to inform.
2015-05-24 Nathan Sidwell <nathan@acm.org> 2015-05-24 Nathan Sidwell <nathan@acm.org>
PR c++/66243 PR c++/66243
......
...@@ -1181,7 +1181,7 @@ warn_extern_redeclared_static (tree newdecl, tree olddecl) ...@@ -1181,7 +1181,7 @@ warn_extern_redeclared_static (tree newdecl, tree olddecl)
&& DECL_ARTIFICIAL (olddecl)) && DECL_ARTIFICIAL (olddecl))
return; return;
if (permerror (input_location, if (permerror (DECL_SOURCE_LOCATION (newdecl),
"%qD was declared %<extern%> and later %<static%>", newdecl)) "%qD was declared %<extern%> and later %<static%>", newdecl))
inform (input_location, "previous declaration of %q+D", olddecl); inform (input_location, "previous declaration of %q+D", olddecl);
} }
...@@ -1218,9 +1218,9 @@ check_redeclaration_exception_specification (tree new_decl, ...@@ -1218,9 +1218,9 @@ check_redeclaration_exception_specification (tree new_decl,
&& flag_exceptions && flag_exceptions
&& !comp_except_specs (new_exceptions, old_exceptions, ce_normal)) && !comp_except_specs (new_exceptions, old_exceptions, ce_normal))
{ {
error ("declaration of %qF has a different exception specifier", error ("declaration of %q+F has a different exception specifier",
new_decl); new_decl);
error ("from previous declaration %q+F", old_decl); inform (0, "from previous declaration %q+F", old_decl);
} }
} }
...@@ -1254,7 +1254,7 @@ validate_constexpr_redeclaration (tree old_decl, tree new_decl) ...@@ -1254,7 +1254,7 @@ validate_constexpr_redeclaration (tree old_decl, tree new_decl)
&& DECL_TEMPLATE_SPECIALIZATION (new_decl)) && DECL_TEMPLATE_SPECIALIZATION (new_decl))
return true; return true;
error ("redeclaration %qD differs in %<constexpr%>", new_decl); error ("redeclaration %q+D differs in %<constexpr%>", new_decl);
error ("from previous declaration %q+D", old_decl); error ("from previous declaration %q+D", old_decl);
return false; return false;
} }
...@@ -1276,7 +1276,7 @@ check_redeclaration_no_default_args (tree decl) ...@@ -1276,7 +1276,7 @@ check_redeclaration_no_default_args (tree decl)
if (TREE_PURPOSE (t)) if (TREE_PURPOSE (t))
{ {
permerror (input_location, permerror (input_location,
"redeclaration of %q#D may not have default " "redeclaration of %q+#D may not have default "
"arguments", decl); "arguments", decl);
return; return;
} }
...@@ -1394,10 +1394,10 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) ...@@ -1394,10 +1394,10 @@ 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 (0, "library function %q#D redeclared as non-function %q#D", warning (0, "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 ("declaration of %q+#D conflicts with built-in "
"declaration %q#D", newdecl, olddecl); "declaration %q#D", newdecl, olddecl);
return NULL_TREE; return NULL_TREE;
} }
...@@ -1457,7 +1457,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) ...@@ -1457,7 +1457,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
/* A near match; override the builtin. */ /* A near match; override the builtin. */
if (TREE_PUBLIC (newdecl)) if (TREE_PUBLIC (newdecl))
warning (0, "new declaration %q#D ambiguates built-in " warning (0, "new declaration %q+#D ambiguates built-in "
"declaration %q#D", newdecl, olddecl); "declaration %q#D", newdecl, olddecl);
else else
warning (OPT_Wshadow, warning (OPT_Wshadow,
...@@ -1571,7 +1571,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) ...@@ -1571,7 +1571,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
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 ("conflicting declaration of template %q+#D", newdecl);
inform (DECL_SOURCE_LOCATION (olddecl), inform (DECL_SOURCE_LOCATION (olddecl),
"previous declaration %q#D", olddecl); "previous declaration %q#D", olddecl);
return error_mark_node; return error_mark_node;
...@@ -1587,7 +1587,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) ...@@ -1587,7 +1587,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
&& same_type_p (TREE_TYPE (TREE_TYPE (newdecl)), && same_type_p (TREE_TYPE (TREE_TYPE (newdecl)),
TREE_TYPE (TREE_TYPE (olddecl)))) TREE_TYPE (TREE_TYPE (olddecl))))
{ {
error ("ambiguating new declaration %q#D", newdecl); error ("ambiguating new declaration %q+#D", newdecl);
inform (DECL_SOURCE_LOCATION (olddecl), inform (DECL_SOURCE_LOCATION (olddecl),
"old declaration %q#D", olddecl); "old declaration %q#D", olddecl);
} }
...@@ -1597,7 +1597,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) ...@@ -1597,7 +1597,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
{ {
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 ("conflicting declaration of C function %q+#D",
newdecl); newdecl);
inform (DECL_SOURCE_LOCATION (olddecl), inform (DECL_SOURCE_LOCATION (olddecl),
"previous declaration %q#D", olddecl); "previous declaration %q#D", olddecl);
...@@ -1610,7 +1610,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) ...@@ -1610,7 +1610,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
&& compparms (TYPE_ARG_TYPES (TREE_TYPE (newdecl)), && compparms (TYPE_ARG_TYPES (TREE_TYPE (newdecl)),
TYPE_ARG_TYPES (TREE_TYPE (olddecl)))) TYPE_ARG_TYPES (TREE_TYPE (olddecl))))
{ {
error ("ambiguating new declaration of %q#D", newdecl); error ("ambiguating new declaration of %q+#D", newdecl);
inform (DECL_SOURCE_LOCATION (olddecl), inform (DECL_SOURCE_LOCATION (olddecl),
"old declaration %q#D", olddecl); "old declaration %q#D", olddecl);
return error_mark_node; return error_mark_node;
...@@ -1620,7 +1620,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) ...@@ -1620,7 +1620,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
} }
else else
{ {
error ("conflicting declaration %q#D", newdecl); error ("conflicting declaration %q+#D", newdecl);
inform (DECL_SOURCE_LOCATION (olddecl), inform (DECL_SOURCE_LOCATION (olddecl),
"previous declaration as %q#D", olddecl); "previous declaration as %q#D", olddecl);
return error_mark_node; return error_mark_node;
...@@ -1674,7 +1674,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) ...@@ -1674,7 +1674,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
A namespace-name defined at global scope shall not be A namespace-name defined at global scope shall not be
declared as the name of any other entity in any global scope declared as the name of any other entity in any global scope
of the program. */ of the program. */
error ("conflicting declaration of namespace %qD", newdecl); error ("conflicting declaration of namespace %q+D", newdecl);
inform (DECL_SOURCE_LOCATION (olddecl), inform (DECL_SOURCE_LOCATION (olddecl),
"previous declaration of namespace %qD here", olddecl); "previous declaration of namespace %qD here", olddecl);
return error_mark_node; return error_mark_node;
...@@ -1699,7 +1699,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) ...@@ -1699,7 +1699,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
{ {
/* 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 (DECL_SOURCE_LOCATION (newdecl), 0,
"prototype specified for %q#D", newdecl)) "prototype specified for %q+#D", newdecl))
inform (DECL_SOURCE_LOCATION (olddecl), inform (DECL_SOURCE_LOCATION (olddecl),
"previous non-prototype definition here"); "previous non-prototype definition here");
} }
...@@ -1740,7 +1740,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) ...@@ -1740,7 +1740,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
} }
else else
{ {
error ("conflicting declaration of %q#D with %qL linkage", error ("conflicting declaration of %q+#D with %qL linkage",
newdecl, DECL_LANGUAGE (newdecl)); newdecl, DECL_LANGUAGE (newdecl));
inform (DECL_SOURCE_LOCATION (olddecl), inform (DECL_SOURCE_LOCATION (olddecl),
"previous declaration with %qL linkage", "previous declaration with %qL linkage",
...@@ -1853,7 +1853,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) ...@@ -1853,7 +1853,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
|| DECL_TEMPLATE_SPECIALIZATION (olddecl))) || DECL_TEMPLATE_SPECIALIZATION (olddecl)))
{ {
if (warning (OPT_Wredundant_decls, if (warning (OPT_Wredundant_decls,
"redundant redeclaration of %qD in same scope", "redundant redeclaration of %q+D in same scope",
newdecl)) newdecl))
inform (DECL_SOURCE_LOCATION (olddecl), inform (DECL_SOURCE_LOCATION (olddecl),
"previous declaration of %qD", olddecl); "previous declaration of %qD", olddecl);
...@@ -1864,7 +1864,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) ...@@ -1864,7 +1864,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
{ {
if (DECL_DELETED_FN (newdecl)) if (DECL_DELETED_FN (newdecl))
{ {
error ("deleted definition of %qD", newdecl); error ("deleted definition of %q+D", newdecl);
inform (DECL_SOURCE_LOCATION (olddecl), inform (DECL_SOURCE_LOCATION (olddecl),
"previous declaration of %qD", olddecl); "previous declaration of %qD", olddecl);
} }
......
...@@ -10,7 +10,7 @@ void f(); ...@@ -10,7 +10,7 @@ void f();
SA(!noexcept(f())); SA(!noexcept(f()));
void g() throw (int); // { dg-error "previous declaration" } void g() throw (int); // { dg-message "previous declaration" }
void g() noexcept(false); // { dg-error "different exception" } void g() noexcept(false); // { dg-error "different exception" }
void g(); void g();
...@@ -20,7 +20,7 @@ void h() throw(); ...@@ -20,7 +20,7 @@ void h() throw();
void h() noexcept; void h() noexcept;
template <class T> template <class T>
void g (T) noexcept(noexcept(T())); // { dg-error "previous declaration" } void g (T) noexcept(noexcept(T())); // { dg-message "previous declaration" }
template <class T> template <class T>
void g (T) noexcept(noexcept(T(0))); // { dg-error "different exception" } void g (T) noexcept(noexcept(T(0))); // { dg-error "different exception" }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
struct exception {}; struct exception {};
template <typename T> void foo() throw(exception); // { dg-error "declaration" } template <typename T> void foo() throw(exception); // { dg-message "declaration" }
template <typename T> void foo(); // { dg-error "exception" } template <typename T> void foo(); // { dg-error "exception" }
struct bar struct bar
......
#define FOO __attribute__ (()) // { dg-bogus "" }
void f() throw(); // { dg-message "" }
void f() FOO; // { dg-error "" }
// Test for proper error message formatting; the throw() should go inside // Test for proper error message formatting; the throw() should go inside
// the parens, as below. // the parens, as below.
void (*g() throw())(); // { dg-error "g\\(\\) throw" "" } void (*g() throw())(); // { dg-message "g\\(\\) throw" "" }
void (*g())(); // { dg-error "" "" } void (*g())(); // { dg-error "" "" }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
template <typename T> template <typename T>
class foo { class foo {
void bar() throw(int); // { dg-error "throw \\(int\\)" } void bar() throw(int); // { dg-message "throw \\(int\\)" }
}; };
template <> template <>
......
...@@ -43,32 +43,32 @@ void baz3() throw(Int, char){} // typedefs are the same type ... ...@@ -43,32 +43,32 @@ void baz3() throw(Int, char){} // typedefs are the same type ...
void baz4() throw(int, Int, char); // ... so this is a duplicate void baz4() throw(int, Int, char); // ... so this is a duplicate
void baz4() throw(Int, char){} void baz4() throw(Int, char){}
void fna() throw(int, char); // { dg-error "" } to previous declaration void fna() throw(int, char); // { dg-message "" } to previous declaration
void fna() throw(int const, char); // { dg-error "" } declaration different exceptions // ERROR - to previous declaration void fna() throw(int const, char); // { dg-error "" } declaration different exceptions // ERROR - to previous declaration
void fna() throw(int){} // { dg-error "" } declaration different exceptions void fna() throw(int){} // { dg-error "" } declaration different exceptions
void fnb() throw(int, char); // { dg-error "" } to previous declaration void fnb() throw(int, char); // { dg-message "" } to previous declaration
void fnb() throw(char){} // { dg-error "" } declaration different exceptions void fnb() throw(char){} // { dg-error "" } declaration different exceptions
void fnc() throw(int, char); // { dg-error "" } to previous declaration void fnc() throw(int, char); // { dg-message "" } to previous declaration
void fnc() throw(char, int, float){} // { dg-error "" } declaration different exceptions void fnc() throw(char, int, float){} // { dg-error "" } declaration different exceptions
void fnd() throw(); // { dg-error "" } to previous declaration void fnd() throw(); // { dg-message "" } to previous declaration
void fnd() throw(char){} // { dg-error "" } declaration different exceptions void fnd() throw(char){} // { dg-error "" } declaration different exceptions
void fne() throw(char); // { dg-error "" } to previous declaration void fne() throw(char); // { dg-message "" } to previous declaration
void fne() throw(){} // { dg-error "" } declaration different exceptions void fne() throw(){} // { dg-error "" } declaration different exceptions
void fnf(); // { dg-error "" } to previous declaration void fnf(); // { dg-message "" } to previous declaration
void fnf() throw(char){} // { dg-error "" } declaration different exceptions void fnf() throw(char){} // { dg-error "" } declaration different exceptions
void fng() throw(char); // { dg-error "" } to previous declaration void fng() throw(char); // { dg-message "" } to previous declaration
void fng(){} // { dg-error "" } declaration different exceptions void fng(){} // { dg-error "" } declaration different exceptions
void fnh() throw(int, char); // { dg-error "" } to previous declaration void fnh() throw(int, char); // { dg-message "" } to previous declaration
void fnh() throw(int, float){} // { dg-error "" } declaration different exceptions void fnh() throw(int, float){} // { dg-error "" } declaration different exceptions
void fni() throw(int, char); // { dg-error "" } to previous declaration void fni() throw(int, char); // { dg-message "" } to previous declaration
void fni() throw(float, char){} // { dg-error "" } declaration different exceptions void fni() throw(float, char){} // { dg-error "" } declaration different exceptions
// [except.spec] 3, virtual function overriders shall throw a subset of the // [except.spec] 3, virtual function overriders shall throw a subset of the
......
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