Tested x86_64-linux. Is the g++ test change OK?
Also available for review at:
https://forge.sourceware.org/gcc/gcc-TEST/pulls/4
-- >8 --
These headers make no sense for C++ programs, because they either define
different content to the corresponding <xxx.h> C header, or define
nothing at all in namespace std. They were all deprecated in C++17, so
add deprecation warnings to them, which can be disabled with
-Wno-deprecated. For C++20 and later these headers are no longer in the
standard at all, so compiling with _GLIBCXX_USE_DEPRECATED defined to 0
will give an error when they are included.
Because #warning is non-standard before C++23 we need to use pragmas to
ignore -Wc++23-extensions for the -Wsystem-headers -pedantic case.
One g++ test needs adjustment because it includes <ciso646>, but that
can be made conditional on the __cplusplus value without any reduction
in test coverage.
For the library tests, consolidate the std_c++0x_neg.cc XFAIL tests into
the macros.cc test, using dg-error with a { target c++98_only }
selector. This avoids having two separate test files, one for C++98 and
one for everything later. Also add tests for the <xxx.h> headers to
ensure that they behave as expected and don't give deprecated warnings.
libstdc++-v3/ChangeLog:
* doc/xml/manual/evolution.xml: Document deprecations.
* doc/html/*: Regenerate.
* include/c_compatibility/complex.h (_GLIBCXX_COMPLEX_H): Move
include guard to start of file. Include <complex> directly
instead of <ccomplex>.
* include/c_compatibility/tgmath.h: Include <cmath> and
<complex> directly, instead of <ctgmath>.
* include/c_global/ccomplex: Add deprecated #warning for C++17
and #error for C++20 if _GLIBCXX_USE_DEPRECATED == 0.
* include/c_global/ciso646: Likewise.
* include/c_global/cstdalign: Likewise.
* include/c_global/cstdbool: Likewise.
* include/c_global/ctgmath: Likewise.
* include/c_std/ciso646: Likewise.
* include/precompiled/stdc++.h: Do not include ccomplex,
ciso646, cstdalign, cstdbool, or ctgmath in C++17 and later.
* testsuite/18_support/headers/cstdalign/macros.cc: Check for
warnings and errors for unsupported dialects.
* testsuite/18_support/headers/cstdbool/macros.cc: Likewise.
* testsuite/26_numerics/headers/ctgmath/complex.cc: Likewise.
* testsuite/27_io/objects/char/1.cc: Do not include <ciso646>.
* testsuite/27_io/objects/wchar_t/1.cc: Likewise.
* testsuite/18_support/headers/cstdbool/std_c++0x_neg.cc: Removed.
* testsuite/18_support/headers/cstdalign/std_c++0x_neg.cc: Removed.
* testsuite/26_numerics/headers/ccomplex/std_c++0x_neg.cc: Removed.
* testsuite/26_numerics/headers/ctgmath/std_c++0x_neg.cc: Removed.
* testsuite/18_support/headers/ciso646/macros.cc: New test.
* testsuite/18_support/headers/ciso646/macros.h.cc: New test.
* testsuite/18_support/headers/cstdbool/macros.h.cc: New test.
* testsuite/26_numerics/headers/ccomplex/complex.cc: New test.
* testsuite/26_numerics/headers/ccomplex/complex.h.cc: New test.
* testsuite/26_numerics/headers/ctgmath/complex.h.cc: New test.
gcc/testsuite/ChangeLog:
* g++.old-deja/g++.other/headers1.C: Do not include ciso646 for
C++17 and later.
---
.../g++.old-deja/g++.other/headers1.C | 2 +
libstdc++-v3/doc/html/manual/api.html | 8 +++
libstdc++-v3/doc/xml/manual/evolution.xml | 10 ++++
.../include/c_compatibility/complex.h | 10 ++--
libstdc++-v3/include/c_compatibility/tgmath.h | 11 ++--
libstdc++-v3/include/c_global/ccomplex | 9 ++++
libstdc++-v3/include/c_global/ciso646 | 9 ++++
libstdc++-v3/include/c_global/cstdalign | 8 +++
libstdc++-v3/include/c_global/cstdbool | 8 +++
libstdc++-v3/include/c_global/ctgmath | 14 +++--
libstdc++-v3/include/c_std/ciso646 | 10 ++++
libstdc++-v3/include/precompiled/stdc++.h | 13 +++--
.../18_support/headers/ciso646/macros.cc | 51 +++++++++++++++++++
.../18_support/headers/ciso646/macros.h.cc | 49 ++++++++++++++++++
.../18_support/headers/cstdalign/macros.cc | 10 +++-
.../18_support/headers/cstdalign/macros.h.cc | 25 +++++++++
.../headers/cstdalign/std_c++0x_neg.cc | 24 ---------
.../18_support/headers/cstdbool/macros.cc | 9 +++-
.../18_support/headers/cstdbool/macros.h.cc | 21 ++++++++
.../headers/cstdbool/std_c++0x_neg.cc | 26 ----------
.../26_numerics/headers/ccomplex/complex.cc | 10 ++++
.../26_numerics/headers/ccomplex/complex.h.cc | 10 ++++
.../headers/ccomplex/std_c++0x_neg.cc | 26 ----------
.../26_numerics/headers/ctgmath/complex.cc | 9 +++-
.../26_numerics/headers/ctgmath/complex.h.cc | 10 ++++
.../headers/ctgmath/std_c++0x_neg.cc | 26 ----------
.../testsuite/27_io/objects/char/1.cc | 1 -
.../testsuite/27_io/objects/wchar_t/1.cc | 1 -
28 files changed, 294 insertions(+), 126 deletions(-)
create mode 100644 libstdc++-v3/testsuite/18_support/headers/ciso646/macros.cc
create mode 100644 libstdc++-v3/testsuite/18_support/headers/ciso646/macros.h.cc
create mode 100644
libstdc++-v3/testsuite/18_support/headers/cstdalign/macros.h.cc
delete mode 100644
libstdc++-v3/testsuite/18_support/headers/cstdalign/std_c++0x_neg.cc
create mode 100644
libstdc++-v3/testsuite/18_support/headers/cstdbool/macros.h.cc
delete mode 100644
libstdc++-v3/testsuite/18_support/headers/cstdbool/std_c++0x_neg.cc
create mode 100644
libstdc++-v3/testsuite/26_numerics/headers/ccomplex/complex.cc
create mode 100644
libstdc++-v3/testsuite/26_numerics/headers/ccomplex/complex.h.cc
delete mode 100644
libstdc++-v3/testsuite/26_numerics/headers/ccomplex/std_c++0x_neg.cc
create mode 100644
libstdc++-v3/testsuite/26_numerics/headers/ctgmath/complex.h.cc
delete mode 100644
libstdc++-v3/testsuite/26_numerics/headers/ctgmath/std_c++0x_neg.cc
diff --git a/gcc/testsuite/g++.old-deja/g++.other/headers1.C
b/gcc/testsuite/g++.old-deja/g++.other/headers1.C
index 5d37e94082f..90a1a7dc8f9 100644
--- a/gcc/testsuite/g++.old-deja/g++.other/headers1.C
+++ b/gcc/testsuite/g++.old-deja/g++.other/headers1.C
@@ -12,7 +12,9 @@
#include <cctype>
#include <cerrno>
#include <cfloat>
+#if __cplusplus < 201703L
#include <ciso646>
+#endif
#include <climits>
#include <clocale>
#include <cmath>
diff --git a/libstdc++-v3/doc/html/manual/api.html
b/libstdc++-v3/doc/html/manual/api.html
index 799f6eae2a2..2ccfc07b83e 100644
--- a/libstdc++-v3/doc/html/manual/api.html
+++ b/libstdc++-v3/doc/html/manual/api.html
@@ -498,4 +498,12 @@ to be used with <code
class="code">std::basic_istream</code>.
longer allowed in C++20 mode.
</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="api.rel_151"></a><code
class="constant">15</code></h3></div></div></div><p>
Enabled debug assertions by default for unoptimized builds.
+</p><p>
+Added warnings when including the headers that were deprecated in C++17
+and removed in C++20:
+<code class="filename"><ccomplex></code>,
+<code class="filename"><ciso646></code>,
+<code class="filename"><cstdalign></code>,
+<code class="filename"><cstdbool></code>, and
+<code class="filename"><ctgmath></code>.
</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="abi.html">Prev</a>??</td><td width="20%" align="center"><a accesskey="u" href="appendix_porting.html">Up</a></td><td width="40%" align="right">??<a
accesskey="n" href="backwards.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">ABI Policy and Guidelines??</td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top">??Backwards
Compatibility</td></tr></table></div></body></html>
\ No newline at end of file
diff --git a/libstdc++-v3/doc/xml/manual/evolution.xml
b/libstdc++-v3/doc/xml/manual/evolution.xml
index 75cf948a4a2..6b134de0e71 100644
--- a/libstdc++-v3/doc/xml/manual/evolution.xml
+++ b/libstdc++-v3/doc/xml/manual/evolution.xml
@@ -1135,6 +1135,16 @@ to be used with <code>std::basic_istream</code>.
Enabled debug assertions by default for unoptimized builds.
</para>
+<para>
+Added warnings when including the headers that were deprecated in C++17
+and removed in C++20:
+<filename class="headerfile"><ccomplex></filename>,
+<filename class="headerfile"><ciso646></filename>,
+<filename class="headerfile"><cstdalign></filename>,
+<filename class="headerfile"><cstdbool></filename>, and
+<filename class="headerfile"><ctgmath></filename>.
+</para>
+
</section>
</section>
diff --git a/libstdc++-v3/include/c_compatibility/complex.h
b/libstdc++-v3/include/c_compatibility/complex.h
index 605d1f30e06..461ff2117b1 100644
--- a/libstdc++-v3/include/c_compatibility/complex.h
+++ b/libstdc++-v3/include/c_compatibility/complex.h
@@ -26,10 +26,15 @@
* This is a Standard C++ Library header.
*/
+#ifndef _GLIBCXX_COMPLEX_H
+#define _GLIBCXX_COMPLEX_H 1
+
#include <bits/c++config.h>
#if __cplusplus >= 201103L
-# include <ccomplex>
+extern "C++" {
+#include <complex>
+}
#endif
#if __cplusplus >= 201103L && defined(__STRICT_ANSI__)
@@ -42,7 +47,4 @@
# endif
#endif
-#ifndef _GLIBCXX_COMPLEX_H
-#define _GLIBCXX_COMPLEX_H 1
-
#endif
diff --git a/libstdc++-v3/include/c_compatibility/tgmath.h
b/libstdc++-v3/include/c_compatibility/tgmath.h
index aadddd91b60..6bf6727a15c 100644
--- a/libstdc++-v3/include/c_compatibility/tgmath.h
+++ b/libstdc++-v3/include/c_compatibility/tgmath.h
@@ -32,11 +32,12 @@
#include <bits/c++config.h>
#if __cplusplus >= 201103L
-# include <ctgmath>
-#else
-# if _GLIBCXX_HAVE_TGMATH_H
-# include_next <tgmath.h>
-# endif
+# include <cmath>
+extern "C++" {
+# include <complex>
+}
+#elif _GLIBCXX_HAVE_TGMATH_H
+# include_next <tgmath.h>
#endif
#endif
diff --git a/libstdc++-v3/include/c_global/ccomplex
b/libstdc++-v3/include/c_global/ccomplex
index ee1166aaecb..b0e30fa67eb 100644
--- a/libstdc++-v3/include/c_global/ccomplex
+++ b/libstdc++-v3/include/c_global/ccomplex
@@ -41,4 +41,13 @@ extern "C++" {
#include <complex>
}
+#if __cplusplus >= 202002L && ! _GLIBCXX_USE_DEPRECATED
+# error "<ccomplex> is not a standard header in C++20, use <complex.h>"
+#elif __cplusplus >= 201703L && defined __DEPRECATED
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wc++23-extensions"
+# warning "<ccomplex> is deprecated in C++17, use <complex.h>"