* C++ PATCH to handling of exception specs in system headers
@ 2015-05-27 20:59 Jason Merrill
2015-06-01 12:13 ` Rainer Orth
0 siblings, 1 reply; 6+ messages in thread
From: Jason Merrill @ 2015-05-27 20:59 UTC (permalink / raw)
To: gcc-patches List
[-- Attachment #1: Type: text/plain, Size: 330 bytes --]
-pedantic shouldn't change something from OK into an error, but it was
doing so for redeclaration of a declaration from a system header with a
mismatched exception specification. And whether we are strict about
things in system headers should be controlled by -Wsystem-headers.
Tested x86_64-pc-linux-gnu, applying to trunk.
[-- Attachment #2: ped-sys.patch --]
[-- Type: text/x-patch, Size: 2085 bytes --]
commit 8c029a40a7d4348c432f09eb2512a485cfe9bda8
Author: Jason Merrill <jason@redhat.com>
Date: Tue May 26 11:47:27 2015 -0400
* decl.c (check_redeclaration_exception_specification): Depend on
-Wsystem-headers rather than -pedantic.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 420c7f40..a8cb358 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 0000000..ac5c30d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wsystem-headers1.C
@@ -0,0 +1,3 @@
+#include <stdlib.h>
+
+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 0000000..68f6ea1
--- /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 <stdlib.h>
+
+extern double atof (const char *); // { dg-warning "different exception spec" }
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: C++ PATCH to handling of exception specs in system headers
2015-05-27 20:59 C++ PATCH to handling of exception specs in system headers Jason Merrill
@ 2015-06-01 12:13 ` Rainer Orth
2015-06-01 14:58 ` Jason Merrill
0 siblings, 1 reply; 6+ messages in thread
From: Rainer Orth @ 2015-06-01 12:13 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches List
Jason Merrill <jason@redhat.com> writes:
> -pedantic shouldn't change something from OK into an error, but it was
> doing so for redeclaration of a declaration from a system header with a
> mismatched exception specification. And whether we are strict about things
> in system headers should be controlled by -Wsystem-headers.
>
> Tested x86_64-pc-linux-gnu, applying to trunk.
The new g++.dg/warn/Wsystem-headers1.C test FAILs on Solaris 10 and 11:
FAIL: g++.dg/warn/Wsystem-headers1.C -std=c++98 (test for excess errors)
/vol/gcc/src/hg/trunk/local/gcc/testsuite/g++.dg/warn/Wsystem-headers1.C:3:33: error: 'double atof(const char*)' conflicts with a previous declaration
In file included from /usr/include/stdlib.h:17:0,
from /vol/gcc/src/hg/trunk/local/gcc/testsuite/g++.dg/warn/Wsystem-headers1.C:1:
/var/gcc/regression/trunk/10-gcc/build/gcc/include-fixed/iso/stdlib_iso.h:119:15: note: previous declaration 'double std::atof(const char*)'
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: C++ PATCH to handling of exception specs in system headers
2015-06-01 12:13 ` Rainer Orth
@ 2015-06-01 14:58 ` Jason Merrill
2015-06-01 15:34 ` Rainer Orth
0 siblings, 1 reply; 6+ messages in thread
From: Jason Merrill @ 2015-06-01 14:58 UTC (permalink / raw)
To: Rainer Orth; +Cc: gcc-patches List
On 06/01/2015 08:13 AM, Rainer Orth wrote:
> Jason Merrill <jason@redhat.com> writes:
>
>> -pedantic shouldn't change something from OK into an error, but it was
>> doing so for redeclaration of a declaration from a system header with a
>> mismatched exception specification. And whether we are strict about things
>> in system headers should be controlled by -Wsystem-headers.
>>
>> Tested x86_64-pc-linux-gnu, applying to trunk.
>
> The new g++.dg/warn/Wsystem-headers1.C test FAILs on Solaris 10 and 11:
>
> FAIL: g++.dg/warn/Wsystem-headers1.C -std=c++98 (test for excess errors)
>
> /vol/gcc/src/hg/trunk/local/gcc/testsuite/g++.dg/warn/Wsystem-headers1.C:3:33: error: 'double atof(const char*)' conflicts with a previous declaration
> In file included from /usr/include/stdlib.h:17:0,
> from /vol/gcc/src/hg/trunk/local/gcc/testsuite/g++.dg/warn/Wsystem-headers1.C:1:
> /var/gcc/regression/trunk/10-gcc/build/gcc/include-fixed/iso/stdlib_iso.h:119:15: note: previous declaration 'double std::atof(const char*)'
It's not clear what the conflict is. Can you quote the declaration from
stdlib_iso.h?
Jason
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: C++ PATCH to handling of exception specs in system headers
2015-06-01 14:58 ` Jason Merrill
@ 2015-06-01 15:34 ` Rainer Orth
2015-06-01 17:05 ` Jason Merrill
0 siblings, 1 reply; 6+ messages in thread
From: Rainer Orth @ 2015-06-01 15:34 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches List
Jason Merrill <jason@redhat.com> writes:
> On 06/01/2015 08:13 AM, Rainer Orth wrote:
>> Jason Merrill <jason@redhat.com> writes:
>>
>>> -pedantic shouldn't change something from OK into an error, but it was
>>> doing so for redeclaration of a declaration from a system header with a
>>> mismatched exception specification. And whether we are strict about things
>>> in system headers should be controlled by -Wsystem-headers.
>>>
>>> Tested x86_64-pc-linux-gnu, applying to trunk.
>>
>> The new g++.dg/warn/Wsystem-headers1.C test FAILs on Solaris 10 and 11:
>>
>> FAIL: g++.dg/warn/Wsystem-headers1.C -std=c++98 (test for excess errors)
>>
>> /vol/gcc/src/hg/trunk/local/gcc/testsuite/g++.dg/warn/Wsystem-headers1.C:3:33:
>> error: 'double atof(const char*)' conflicts with a previous declaration
>> In file included from /usr/include/stdlib.h:17:0,
>> from
>> /vol/gcc/src/hg/trunk/local/gcc/testsuite/g++.dg/warn/Wsystem-headers1.C:1:
>> /var/gcc/regression/trunk/10-gcc/build/gcc/include-fixed/iso/stdlib_iso.h:119:15:
>> note: previous declaration 'double std::atof(const char*)'
>
> It's not clear what the conflict is. Can you quote the declaration from
> stdlib_iso.h?
sure: it's
extern double atof(const char *);
which is inside
#if __cplusplus >= 199711L
namespace std {
#endif
#ifdef __cplusplus
extern "C" {
#endif
Isn't this about global vs. std namespace?
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: C++ PATCH to handling of exception specs in system headers
2015-06-01 15:34 ` Rainer Orth
@ 2015-06-01 17:05 ` Jason Merrill
2015-06-02 14:19 ` Rainer Orth
0 siblings, 1 reply; 6+ messages in thread
From: Jason Merrill @ 2015-06-01 17:05 UTC (permalink / raw)
To: Rainer Orth; +Cc: gcc-patches List
On 06/01/2015 11:34 AM, Rainer Orth wrote:
> Isn't this about global vs. std namespace?
Probably. Does making the declaration in the testcase extern "C" help?
Jason
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: C++ PATCH to handling of exception specs in system headers
2015-06-01 17:05 ` Jason Merrill
@ 2015-06-02 14:19 ` Rainer Orth
0 siblings, 0 replies; 6+ messages in thread
From: Rainer Orth @ 2015-06-02 14:19 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches List
Jason Merrill <jason@redhat.com> writes:
> On 06/01/2015 11:34 AM, Rainer Orth wrote:
>> Isn't this about global vs. std namespace?
>
> Probably. Does making the declaration in the testcase extern "C" help?
It does indeed, and the test still passes on Linux.
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-06-02 14:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-27 20:59 C++ PATCH to handling of exception specs in system headers Jason Merrill
2015-06-01 12:13 ` Rainer Orth
2015-06-01 14:58 ` Jason Merrill
2015-06-01 15:34 ` Rainer Orth
2015-06-01 17:05 ` Jason Merrill
2015-06-02 14:19 ` Rainer Orth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).