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?