aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2024-07-05 18:39:50 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2024-07-06 21:15:25 +0100
commitdcc735aaeae1cc985a143ade883db748fb10554d (patch)
treec39fc3d6336dcc450e466dce9c1b1e0ea3480336
parent273f16a125c4fab664683376ae04a9a31e7d6a22 (diff)
downloadgcc-dcc735aaeae1cc985a143ade883db748fb10554d.zip
gcc-dcc735aaeae1cc985a143ade883db748fb10554d.tar.gz
gcc-dcc735aaeae1cc985a143ade883db748fb10554d.tar.bz2
libstdc++: Restore support for including <name.h> in extern "C" [PR115797]
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.
-rw-r--r--libstdc++-v3/include/std/type_traits3
-rw-r--r--libstdc++-v3/testsuite/17_intro/headers/c++2011/linkage.cc3
2 files changed, 4 insertions, 2 deletions
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index a31de2e..c39a379 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -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
diff --git a/libstdc++-v3/testsuite/17_intro/headers/c++2011/linkage.cc b/libstdc++-v3/testsuite/17_intro/headers/c++2011/linkage.cc
index c43384e..1825801 100644
--- a/libstdc++-v3/testsuite/17_intro/headers/c++2011/linkage.cc
+++ b/libstdc++-v3/testsuite/17_intro/headers/c++2011/linkage.cc
@@ -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