]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Restore support for including <name.h> in extern "C" [PR115797]
authorJonathan Wakely <jwakely@redhat.com>
Fri, 5 Jul 2024 17:39:50 +0000 (18:39 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Sat, 6 Jul 2024 20:15:25 +0000 (21:15 +0100)
The r15-1857 change means that <type_traits> is included by <cmath> for
C++17 and up, which breaks code including <math.h> inside an extern "C"
block. Although doing that is not allowed by the C++ standard, there's
lots of existing code which incorrectly thinks it's a good idea and so
we try to support it.

libstdc++-v3/ChangeLog:

PR libstdc++/115797
* include/std/type_traits: Ensure "C++" language linkage.
* testsuite/17_intro/headers/c++2011/linkage.cc: Replace
dg-options with c++11 target selector.

libstdc++-v3/include/std/type_traits
libstdc++-v3/testsuite/17_intro/headers/c++2011/linkage.cc

index a31de2ee4abb6ebc779961703855ec555ddd6426..c39a37925376ef0280224c21ed3c05340def8157 100644 (file)
@@ -62,6 +62,8 @@
 #define __glibcxx_want_void_t
 #include <bits/version.h>
 
+extern "C++"
+{
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -4111,6 +4113,7 @@ template<typename _Ret, typename _Fn, typename... _Args>
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std
+} // extern "C++"
 
 #endif  // C++11
 
index c43384efbaa96fe2d5d11887b027a03b8df59f90..1825801cec9c16aad5a699e7500d34dbccba479c 100644 (file)
@@ -15,8 +15,7 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
-// { dg-options "-std=gnu++11" }
-// { dg-do compile }
+// { dg-do compile { target c++11 } }
 
 // libstdc++/69386