From: "Arsen Arsenović" <arsen@aarsen.me>
To: Jonathan Wakely <jwakely@redhat.com>
Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org
Subject: Re: [PATCH 2/4] libstdc++: Add a test for <version> FTM redefinitions
Date: Wed, 05 Apr 2023 13:31:16 +0200 [thread overview]
Message-ID: <86v8iaa7ir.fsf@aarsen.me> (raw)
In-Reply-To: <ZC1Um7egqUh5YfoL@redhat.com>
[-- Attachment #1.1: Type: text/plain, Size: 1683 bytes --]
Jonathan Wakely <jwakely@redhat.com> writes:
> On 05/04/23 01:09 +0200, Arsen Arsenović wrote:
>>This test detects redefinitions by compiling stdc++.h with
>>-Wsystem-headers. Thanks Patrick Palka for the suggestion.
>>
>>libstdc++-v3/ChangeLog:
>>
>> * testsuite/17_intro/versionconflict.cc: New test.
>>---
>> libstdc++-v3/testsuite/17_intro/versionconflict.cc | 6 ++++++
>> 1 file changed, 6 insertions(+)
>> create mode 100644 libstdc++-v3/testsuite/17_intro/versionconflict.cc
>>
>>diff --git a/libstdc++-v3/testsuite/17_intro/versionconflict.cc b/libstdc++-v3/testsuite/17_intro/versionconflict.cc
>>new file mode 100644
>>index 00000000000..4191c7a2b08
>>--- /dev/null
>>+++ b/libstdc++-v3/testsuite/17_intro/versionconflict.cc
>>@@ -0,0 +1,6 @@
>>+// { dg-do preprocess }
>>+// { dg-additional-options "-Wsystem-headers -Werror" }
>>+
>>+// Test for redefinitions of FTMs using bits/stdc++.h.
>>+#include <bits/stdc++.h>
>>+#include <version>
>
> I'm concerned that this will fail if libc headers have macro
> redefinition errors, or anything else that would usually be ignored.
>
> We could make it more robust by changing <version> like so:
>
> --- a/libstdc++-v3/include/std/version
> +++ b/libstdc++-v3/include/std/version
> @@ -30,7 +30,9 @@
> #ifndef _GLIBCXX_VERSION_INCLUDED
> #define _GLIBCXX_VERSION_INCLUDED
> +#ifndef _GLIBCXX_TESTING_SYSHDR
> #pragma GCC system_header
> +#endif
> #include <bits/c++config.h>
> Then the test could define that macro instead of using -Wsystem-headers.
>
> Could you see if that works?
Good idea. Both the positive and negative cases work when implemented
like this:
[-- Attachment #1.2: (v2) libstdc++: Add a test for <version> FTM redefinitions --]
[-- Type: text/plain, Size: 1684 bytes --]
From 98d302bab9a87d3f2daecf9d54d62f33ba216673 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Arsen=20Arsenovi=C4=87?= <arsen@aarsen.me>
Date: Wed, 8 Mar 2023 17:01:24 +0100
Subject: [PATCH 2/4] libstdc++: Add a test for <version> FTM redefinitions
This test detects redefinitions by compiling stdc++.h with
-Wsystem-headers. Thanks Patrick Palka for the suggestion.
libstdc++-v3/ChangeLog:
* testsuite/17_intro/versionconflict.cc: New test.
---
libstdc++-v3/include/std/version | 5 ++++-
libstdc++-v3/testsuite/17_intro/versionconflict.cc | 7 +++++++
2 files changed, 11 insertions(+), 1 deletion(-)
create mode 100644 libstdc++-v3/testsuite/17_intro/versionconflict.cc
diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version
index cdd24248c57..1069bc6c9f6 100644
--- a/libstdc++-v3/include/std/version
+++ b/libstdc++-v3/include/std/version
@@ -30,7 +30,10 @@
#ifndef _GLIBCXX_VERSION_INCLUDED
#define _GLIBCXX_VERSION_INCLUDED
-#pragma GCC system_header
+// To facilitate testsuite/17_intro/versionconflict.cc
+#ifndef _GLIBCXX_TESTING_SYSHDR
+# pragma GCC system_header
+#endif
#include <bits/c++config.h>
diff --git a/libstdc++-v3/testsuite/17_intro/versionconflict.cc b/libstdc++-v3/testsuite/17_intro/versionconflict.cc
new file mode 100644
index 00000000000..6c212980ab0
--- /dev/null
+++ b/libstdc++-v3/testsuite/17_intro/versionconflict.cc
@@ -0,0 +1,7 @@
+// { dg-do preprocess }
+// { dg-additional-options "-Werror" }
+
+// Test for redefinitions of FTMs using bits/stdc++.h.
+#define _GLIBCXX_TESTING_SYSHDR
+#include <bits/stdc++.h>
+#include <version>
--
2.40.0
[-- Attachment #1.3: Type: text/plain, Size: 23 bytes --]
--
Arsen Arsenović
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 381 bytes --]
next prev parent reply other threads:[~2023-04-05 11:33 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-04 23:09 [PATCH 1/4] libstdc++: Harmonize <version> and other headers Arsen Arsenović
2023-04-04 23:09 ` [PATCH 2/4] libstdc++: Add a test for <version> FTM redefinitions Arsen Arsenović
2023-04-05 10:59 ` Jonathan Wakely
2023-04-05 11:31 ` Arsen Arsenović [this message]
2023-04-05 11:38 ` Arsen Arsenović
2023-04-05 12:07 ` Jonathan Wakely
2023-04-04 23:09 ` [PATCH 3/4] libstdc++: Downgrade DEBUG to ASSERTIONS when !HOSTED Arsen Arsenović
2023-04-05 11:00 ` Jonathan Wakely
2023-04-04 23:09 ` [PATCH 4/4] libstdc++: Fix some freestanding test failures Arsen Arsenović
2023-04-05 11:08 ` Jonathan Wakely
2023-04-05 11:28 ` Arsen Arsenović
2023-04-05 10:52 ` [PATCH 1/4] libstdc++: Harmonize <version> and other headers Jonathan Wakely
2023-04-05 11:33 ` Arsen Arsenović
2023-04-05 12:09 ` Jonathan Wakely
2023-04-05 12:10 ` Jonathan Wakely
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86v8iaa7ir.fsf@aarsen.me \
--to=arsen@aarsen.me \
--cc=gcc-patches@gcc.gnu.org \
--cc=jwakely@redhat.com \
--cc=libstdc++@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).