]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Add a test for <version> FTM redefinitions
authorArsen Arsenović <arsen@aarsen.me>
Wed, 8 Mar 2023 16:01:24 +0000 (17:01 +0100)
committerArsen Arsenović <arsen@aarsen.me>
Wed, 5 Apr 2023 16:45:14 +0000 (18:45 +0200)
This test detects redefinitions by compiling stdc++.h and <version>, by
disabling the system_header pragma on the latter, to allow warnings in
it.  Thanks Patrick Palka for the suggestion.

libstdc++-v3/ChangeLog:

* testsuite/17_intro/versionconflict.cc: New test.
* include/std/version: Allow disabling the system_header pragma
via _GLIBCXX_TESTING_SYSHDR.

libstdc++-v3/include/std/version
libstdc++-v3/testsuite/17_intro/versionconflict.cc [new file with mode: 0644]

index cdd24248c57cdf2cb8ea3b2ea6ede5ffb280e51a..1069bc6c9f6f8d933050c1a4118201c843b057a3 100644 (file)
 #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 (file)
index 0000000..6c21298
--- /dev/null
@@ -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>