From cba16cca6232ab9295cfd4ac247b874163712099 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 27 May 2015 16:53:06 -0400 Subject: [PATCH] decl.c (check_redeclaration_exception_specification): Depend on -Wsystem-headers rather than -pedantic. * decl.c (check_redeclaration_exception_specification): Depend on -Wsystem-headers rather than -pedantic. From-SVN: r223778 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/decl.c | 15 ++++++++++----- gcc/testsuite/g++.dg/warn/Wsystem-headers1.C | 3 +++ gcc/testsuite/g++.dg/warn/Wsystem-headers1a.C | 6 ++++++ 4 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/g++.dg/warn/Wsystem-headers1.C create mode 100644 gcc/testsuite/g++.dg/warn/Wsystem-headers1a.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 72dd0eab5bb..774c36e5379 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2015-05-27 Jason Merrill + * decl.c (check_redeclaration_exception_specification): Depend on + -Wsystem-headers rather than -pedantic. + * decl.c (warn_extern_redeclared_static): Use the location of newdecl in diagnostics, not input_location. (validate_constexpr_redeclaration): Likewise. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 420c7f40065..a8cb358965e 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -1213,14 +1213,19 @@ check_redeclaration_exception_specification (tree new_decl, all declarations, including the definition and an explicit specialization, of that function shall have an exception-specification with the same set of type-ids. */ - if ((pedantic || ! DECL_IN_SYSTEM_HEADER (old_decl)) - && ! DECL_IS_BUILTIN (old_decl) + if (! DECL_IS_BUILTIN (old_decl) && flag_exceptions && !comp_except_specs (new_exceptions, old_exceptions, ce_normal)) { - error ("declaration of %q+F has a different exception specifier", - new_decl); - inform (0, "from previous declaration %q+F", old_decl); + const char *msg + = "declaration of %q+F has a different exception specifier"; + bool complained = true; + if (! DECL_IN_SYSTEM_HEADER (old_decl)) + error (msg, new_decl); + else + complained = pedwarn (0, OPT_Wsystem_headers, msg, new_decl); + if (complained) + inform (0, "from previous declaration %q+F", old_decl); } } diff --git a/gcc/testsuite/g++.dg/warn/Wsystem-headers1.C b/gcc/testsuite/g++.dg/warn/Wsystem-headers1.C new file mode 100644 index 00000000000..ac5c30d3dbc --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wsystem-headers1.C @@ -0,0 +1,3 @@ +#include + +extern double atof (const char *); diff --git a/gcc/testsuite/g++.dg/warn/Wsystem-headers1a.C b/gcc/testsuite/g++.dg/warn/Wsystem-headers1a.C new file mode 100644 index 00000000000..68f6ea15f8d --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wsystem-headers1a.C @@ -0,0 +1,6 @@ +// { dg-do compile { target *-*-*gnu } } +// { dg-options "-Wsystem-headers" } + +#include + +extern double atof (const char *); // { dg-warning "different exception spec" } -- 2.30.2