public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Ensure "C++" language linkage for std::abs overloads
@ 2016-10-03 11:31 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2016-10-03 11:31 UTC (permalink / raw)
  To: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 219 bytes --]

	PR libstdc++/77814
	* include/bits/std_abs.h: Use "C++" language linkage.
	* testsuite/17_intro/headers/c++2011/linkage.cc: Move <complex.h> to
	the end. Add <stdalign.h>.

I'll commit to trunk when testing finishes.


[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1892 bytes --]

commit 2dc6b0497b7d0ec0cb298f749419d70a43c2ab70
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Oct 3 12:26:55 2016 +0100

    Ensure "C++" language linkage for std::abs overloads
    
    	PR libstdc++/77814
    	* include/bits/std_abs.h: Use "C++" language linkage.
    	* testsuite/17_intro/headers/c++2011/linkage.cc: Move <complex.h> to
    	the end. Add <stdalign.h>.

diff --git a/libstdc++-v3/include/bits/std_abs.h b/libstdc++-v3/include/bits/std_abs.h
index ab0f980..732b81a3 100644
--- a/libstdc++-v3/include/bits/std_abs.h
+++ b/libstdc++-v3/include/bits/std_abs.h
@@ -43,6 +43,8 @@
 
 #undef abs
 
+extern "C++"
+{
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -103,5 +105,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
+}
 
 #endif // _GLIBCXX_BITS_STD_ABS_H
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 67c384b..bb56dbf 100644
--- a/libstdc++-v3/testsuite/17_intro/headers/c++2011/linkage.cc
+++ b/libstdc++-v3/testsuite/17_intro/headers/c++2011/linkage.cc
@@ -25,9 +25,7 @@
 extern "C"
 {
 #include <assert.h>
-#ifdef _GLIBCXX_HAVE_COMPLEX_H
-#include <complex.h>
-#endif
+// See below for <complex.h>
 #include <ctype.h>
 #include <errno.h>
 #ifdef _GLIBCXX_HAVE_FENV_H
@@ -43,6 +41,9 @@ extern "C"
 #include <math.h>
 #include <setjmp.h>
 #include <signal.h>
+#if _GLIBCXX_HAVE_STDALIGN_H
+#include <stdalign.h>
+#endif
 #include <stdarg.h>
 #ifdef _GLIBCXX_HAVE_STDBOOL_H
 #include <stdbool.h>
@@ -67,4 +68,10 @@ extern "C"
 #ifdef _GLIBCXX_HAVE_WCTYPE_H
 #include <wctype.h>
 #endif
+
+// Include this last, because it adds extern "C++" and so hides problems in
+// other headers if included first (e.g. PR libstdc++/77814).
+#ifdef _GLIBCXX_HAVE_COMPLEX_H
+#include <complex.h>
+#endif
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-10-03 11:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-03 11:31 [PATCH] Ensure "C++" language linkage for std::abs overloads Jonathan Wakely

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).