aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrooks Moses <bmoses@google.com>2015-04-14 03:49:38 +0000
committerBrooks Moses <bmoses@google.com>2015-04-14 03:49:38 +0000
commitdae8f8199df9eae5909e641f9ccd1d73027bdefc (patch)
tree5d97ce181678f2f98485d5933a6c0f6d3ec5239c
parentb3ed81e1a462fae51ad9985dc30186d2d64deb88 (diff)
Make libstdc++'s complex and complex.h modular.
In C++11, this was already essentially the case. C++11 simply removes the C99 <complex.h> and does not make its facilities available. That is a fine and reasonable stance and I've preserved it. I've also removed the unconditional (and dead) undef that was breaking modular builds of the <complex> header. The question is what should <complex.h> and <complex> do in C++98. Currently these two headers conspire to undef 'complex' only when both are included. This doesn't actually work well as it relies on non-modular behavior of observing the order of inclusion. My proposed solution is to simply make including both <complex> and <complex.h> in the same file an error in C++98. This error remains non-modular, but is phrased in a way that should not preclude building this code with modules. In a modular build, the polite error simply won't trigger and instead the user will be faced with a compile error if they ever try to use 'complex' as something other than a macro expanding to '_Complex'. Eventually, we can use an explicit conflict marking in a modules map or other tool to surface this kind of error even to modules builds. git-svn-id: https://gcc.gnu.org/svn/gcc/branches/google/gcc-4_9@222074 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--contrib/testsuite-management/aarch64-grtev4-linux-gnu.xfail4
-rw-r--r--contrib/testsuite-management/powerpc64le-grtev4-linux-gnu.xfail4
-rw-r--r--contrib/testsuite-management/x86_64-grtev4-linux-gnu.xfail4
-rw-r--r--libstdc++-v3/include/c_compatibility/complex.h28
-rw-r--r--libstdc++-v3/include/std/complex10
5 files changed, 38 insertions, 12 deletions
diff --git a/contrib/testsuite-management/aarch64-grtev4-linux-gnu.xfail b/contrib/testsuite-management/aarch64-grtev4-linux-gnu.xfail
index a2a027e5338..a459149ee01 100644
--- a/contrib/testsuite-management/aarch64-grtev4-linux-gnu.xfail
+++ b/contrib/testsuite-management/aarch64-grtev4-linux-gnu.xfail
@@ -18,6 +18,10 @@ FAIL: gcc.dg/wself-assign-1.c (test for warnings, line 20)
FAIL: gcc.dg/wself-assign-1.c (test for warnings, line 21)
FAIL: gcc.dg/wself-assign-1.c (test for warnings, line 22)
+# Also xfailed in x86; Google b/20184248
+FAIL: 17_intro/headers/c++1998/complex.cc (test for excess errors)
+FAIL: 26_numerics/complex/c99.cc (test for excess errors)
+
# AArch64-specific; appear to be missing "loop turned into non-loop; it never loops" output.
FAIL: gcc.dg/unroll_1.c (test for warnings, line 14)
FAIL: gcc.dg/unroll_1.c (test for warnings, line 24)
diff --git a/contrib/testsuite-management/powerpc64le-grtev4-linux-gnu.xfail b/contrib/testsuite-management/powerpc64le-grtev4-linux-gnu.xfail
index 410cdb94311..d8995e0cd1f 100644
--- a/contrib/testsuite-management/powerpc64le-grtev4-linux-gnu.xfail
+++ b/contrib/testsuite-management/powerpc64le-grtev4-linux-gnu.xfail
@@ -18,6 +18,10 @@ FAIL: gcc.dg/wself-assign-1.c (test for warnings, line 20)
FAIL: gcc.dg/wself-assign-1.c (test for warnings, line 21)
FAIL: gcc.dg/wself-assign-1.c (test for warnings, line 22)
+# Also xfailed in x86; Google b/20184248
+FAIL: 17_intro/headers/c++1998/complex.cc (test for excess errors)
+FAIL: 26_numerics/complex/c99.cc (test for excess errors)
+
# PPCle-specific. From PR33512, still failing in truck despite resolved PR.
FAIL: gcc.dg/and-1.c scan-assembler-not nand
diff --git a/contrib/testsuite-management/x86_64-grtev4-linux-gnu.xfail b/contrib/testsuite-management/x86_64-grtev4-linux-gnu.xfail
index a6eb7eca038..b4fa6933791 100644
--- a/contrib/testsuite-management/x86_64-grtev4-linux-gnu.xfail
+++ b/contrib/testsuite-management/x86_64-grtev4-linux-gnu.xfail
@@ -21,6 +21,10 @@ FAIL: gcc.dg/wself-assign-1.c (test for warnings, line 22)
# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60037
FAIL: ext/random/hypergeometric_distribution/operators/values.cc execution test
+# Google b/20184248
+FAIL: 17_intro/headers/c++1998/complex.cc (test for excess errors)
+FAIL: 26_numerics/complex/c99.cc (test for excess errors)
+
# Google b/14137212
FAIL: 29_atomics/atomic/cons/user_pod.cc (test for excess errors)
diff --git a/libstdc++-v3/include/c_compatibility/complex.h b/libstdc++-v3/include/c_compatibility/complex.h
index d072b68a835..b15361ea0d5 100644
--- a/libstdc++-v3/include/c_compatibility/complex.h
+++ b/libstdc++-v3/include/c_compatibility/complex.h
@@ -26,21 +26,29 @@
* This is a Standard C++ Library header.
*/
-#include <bits/c++config.h>
+#ifndef _GLIBCXX_COMPLEX_H
+#define _GLIBCXX_COMPLEX_H 1
#if __cplusplus >= 201103L
# include <ccomplex>
+#else // C++98 and C++03
+
+// The C++ <complex> header is incompatible with the C99 <complex.h> header,
+// they cannot be included into a single translation unit portably. Notably,
+// C++11's <ccomplex> does not include C99's <complex.h> and in C++11's
+// <complex.h> is defined to provide only what C++11's <ccomplex> does in a
+// different namespace.
+#ifdef _GLIBCXX_COMPLEX
+# error Cannot include both <complex> and C99's <complex.h>
#endif
-#if _GLIBCXX_HAVE_COMPLEX_H
-# include_next <complex.h>
-# ifdef _GLIBCXX_COMPLEX
-// See PR56111, keep the macro in C++03 if possible.
-# undef complex
-# endif
-#endif
+// Delegate to a system complex.h if we don't provide it as part of the C++
+// implementation.
+#include_next <complex.h>
-#ifndef _GLIBCXX_COMPLEX_H
-#define _GLIBCXX_COMPLEX_H 1
+// Provide a define indicating that a C99-style <complex.h> has been included.
+#define _GLIBCXX_C99_COMPLEX_H
+
+#endif // C++98 and C++03
#endif
diff --git a/libstdc++-v3/include/std/complex b/libstdc++-v3/include/std/complex
index 941e6b7d845..3104b584eb6 100644
--- a/libstdc++-v3/include/std/complex
+++ b/libstdc++-v3/include/std/complex
@@ -44,8 +44,14 @@
#include <cmath>
#include <sstream>
-// Get rid of a macro possibly defined in <complex.h>
-#undef complex
+// The C++ <complex> header is incompatible with the C99 <complex.h> header,
+// they cannot be included into a single translation unit portably. Notably,
+// C++11's <ccomplex> does not include C99's <complex.h> and in C++11's
+// <complex.h> is defined to provide only what C++11's <ccomplex> does in a
+// different namespace.
+#ifdef _GLIBCXX_C99_COMPLEX_H
+#error Cannot include both <complex> and C99's <complex.h>
+#endif
namespace std _GLIBCXX_VISIBILITY(default)
{