From: Jason Merrill Date: Wed, 27 May 2015 20:52:55 +0000 (-0400) Subject: decl.c (warn_extern_redeclared_static): Use the location of newdecl in diagnostics... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f425298902b6a36fef278c01610afb58dceaec89;p=gcc.git 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 92c47388f74..72dd0eab5bb 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +2015-05-27 Jason Merrill + + * 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 PR c++/66243 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 41530c12947..420c7f40065 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -1181,7 +1181,7 @@ warn_extern_redeclared_static (tree newdecl, tree olddecl) && DECL_ARTIFICIAL (olddecl)) return; - if (permerror (input_location, + if (permerror (DECL_SOURCE_LOCATION (newdecl), "%qD was declared % and later %", newdecl)) inform (input_location, "previous declaration of %q+D", olddecl); } @@ -1218,9 +1218,9 @@ check_redeclaration_exception_specification (tree new_decl, && flag_exceptions && !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); - 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) && DECL_TEMPLATE_SPECIALIZATION (new_decl)) return true; - error ("redeclaration %qD differs in %", new_decl); + error ("redeclaration %q+D differs in %", new_decl); error ("from previous declaration %q+D", old_decl); return false; } @@ -1276,7 +1276,7 @@ check_redeclaration_no_default_args (tree decl) if (TREE_PURPOSE (t)) { permerror (input_location, - "redeclaration of %q#D may not have default " + "redeclaration of %q+#D may not have default " "arguments", decl); return; } @@ -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 it even globally without an error. */ 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); else - error ("declaration of %q#D conflicts with built-in " + error ("declaration of %q+#D conflicts with built-in " "declaration %q#D", newdecl, olddecl); return NULL_TREE; } @@ -1457,7 +1457,7 @@ 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 " + warning (0, "new declaration %q+#D ambiguates built-in " "declaration %q#D", newdecl, olddecl); else warning (OPT_Wshadow, @@ -1571,7 +1571,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) if (TREE_CODE (DECL_TEMPLATE_RESULT (olddecl)) == 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), "previous declaration %q#D", olddecl); return error_mark_node; @@ -1587,7 +1587,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) && same_type_p (TREE_TYPE (TREE_TYPE (newdecl)), TREE_TYPE (TREE_TYPE (olddecl)))) { - error ("ambiguating new declaration %q#D", newdecl); + error ("ambiguating new declaration %q+#D", newdecl); inform (DECL_SOURCE_LOCATION (olddecl), "old declaration %q#D", olddecl); } @@ -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)) { - error ("conflicting declaration of C function %q#D", + error ("conflicting declaration of C function %q+#D", newdecl); inform (DECL_SOURCE_LOCATION (olddecl), "previous declaration %q#D", olddecl); @@ -1610,7 +1610,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) && compparms (TYPE_ARG_TYPES (TREE_TYPE (newdecl)), 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), "old declaration %q#D", olddecl); return error_mark_node; @@ -1620,7 +1620,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) } else { - error ("conflicting declaration %q#D", newdecl); + error ("conflicting declaration %q+#D", newdecl); inform (DECL_SOURCE_LOCATION (olddecl), "previous declaration as %q#D", olddecl); return error_mark_node; @@ -1674,7 +1674,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) A namespace-name defined at global scope shall not be declared as the name of any other entity in any global scope of the program. */ - error ("conflicting declaration of namespace %qD", newdecl); + error ("conflicting declaration of namespace %q+D", newdecl); inform (DECL_SOURCE_LOCATION (olddecl), "previous declaration of namespace %qD here", olddecl); return error_mark_node; @@ -1699,7 +1699,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"); } @@ -1740,7 +1740,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) } else { - error ("conflicting declaration of %q#D with %qL linkage", + error ("conflicting declaration of %q+#D with %qL linkage", newdecl, DECL_LANGUAGE (newdecl)); inform (DECL_SOURCE_LOCATION (olddecl), "previous declaration with %qL linkage", @@ -1853,7 +1853,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) || DECL_TEMPLATE_SPECIALIZATION (olddecl))) { if (warning (OPT_Wredundant_decls, - "redundant redeclaration of %qD in same scope", + "redundant redeclaration of %q+D in same scope", newdecl)) inform (DECL_SOURCE_LOCATION (olddecl), "previous declaration of %qD", olddecl); @@ -1864,7 +1864,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) { if (DECL_DELETED_FN (newdecl)) { - error ("deleted definition of %qD", newdecl); + error ("deleted definition of %q+D", newdecl); inform (DECL_SOURCE_LOCATION (olddecl), "previous declaration of %qD", olddecl); } diff --git a/gcc/testsuite/g++.dg/cpp0x/noexcept02.C b/gcc/testsuite/g++.dg/cpp0x/noexcept02.C index 5d5867af61a..14bb2829fb5 100644 --- a/gcc/testsuite/g++.dg/cpp0x/noexcept02.C +++ b/gcc/testsuite/g++.dg/cpp0x/noexcept02.C @@ -10,7 +10,7 @@ void 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(); @@ -20,7 +20,7 @@ void h() throw(); void h() noexcept; template -void g (T) noexcept(noexcept(T())); // { dg-error "previous declaration" } +void g (T) noexcept(noexcept(T())); // { dg-message "previous declaration" } template void g (T) noexcept(noexcept(T(0))); // { dg-error "different exception" } diff --git a/gcc/testsuite/g++.dg/eh/spec8.C b/gcc/testsuite/g++.dg/eh/spec8.C index 72dadff2257..c76032e3835 100644 --- a/gcc/testsuite/g++.dg/eh/spec8.C +++ b/gcc/testsuite/g++.dg/eh/spec8.C @@ -2,7 +2,7 @@ struct exception {}; -template void foo() throw(exception); // { dg-error "declaration" } +template void foo() throw(exception); // { dg-message "declaration" } template void foo(); // { dg-error "exception" } struct bar diff --git a/gcc/testsuite/g++.dg/ext/attrib51.C b/gcc/testsuite/g++.dg/ext/attrib51.C new file mode 100644 index 00000000000..2683718a0de --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/attrib51.C @@ -0,0 +1,4 @@ +#define FOO __attribute__ (()) // { dg-bogus "" } + +void f() throw(); // { dg-message "" } +void f() FOO; // { dg-error "" } diff --git a/gcc/testsuite/g++.dg/other/error3.C b/gcc/testsuite/g++.dg/other/error3.C index bd5d7010945..37ea51ea845 100644 --- a/gcc/testsuite/g++.dg/other/error3.C +++ b/gcc/testsuite/g++.dg/other/error3.C @@ -1,5 +1,5 @@ // Test for proper error message formatting; the throw() should go inside // the parens, as below. -void (*g() throw())(); // { dg-error "g\\(\\) throw" "" } +void (*g() throw())(); // { dg-message "g\\(\\) throw" "" } void (*g())(); // { dg-error "" "" } diff --git a/gcc/testsuite/g++.dg/template/error36.C b/gcc/testsuite/g++.dg/template/error36.C index b16b976e382..8d3dc63b730 100644 --- a/gcc/testsuite/g++.dg/template/error36.C +++ b/gcc/testsuite/g++.dg/template/error36.C @@ -2,7 +2,7 @@ template class foo { - void bar() throw(int); // { dg-error "throw \\(int\\)" } + void bar() throw(int); // { dg-message "throw \\(int\\)" } }; template <> diff --git a/gcc/testsuite/g++.old-deja/g++.eh/spec6.C b/gcc/testsuite/g++.old-deja/g++.eh/spec6.C index 85e9b4e7c4e..7aa474b12ab 100644 --- a/gcc/testsuite/g++.old-deja/g++.eh/spec6.C +++ b/gcc/testsuite/g++.old-deja/g++.eh/spec6.C @@ -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, 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){} // { 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 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 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 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 fnf(); // { dg-error "" } to previous declaration +void fnf(); // { dg-message "" } to previous declaration 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 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 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 // [except.spec] 3, virtual function overriders shall throw a subset of the