]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Deprecate useless <cxxx> compatibility headers for C++17
authorJonathan Wakely <jwakely@redhat.com>
Wed, 23 Oct 2024 15:01:50 +0000 (16:01 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 6 Nov 2024 12:47:19 +0000 (12:47 +0000)
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.

28 files changed:
gcc/testsuite/g++.old-deja/g++.other/headers1.C
libstdc++-v3/doc/html/manual/api.html
libstdc++-v3/doc/xml/manual/evolution.xml
libstdc++-v3/include/c_compatibility/complex.h
libstdc++-v3/include/c_compatibility/tgmath.h
libstdc++-v3/include/c_global/ccomplex
libstdc++-v3/include/c_global/ciso646
libstdc++-v3/include/c_global/cstdalign
libstdc++-v3/include/c_global/cstdbool
libstdc++-v3/include/c_global/ctgmath
libstdc++-v3/include/c_std/ciso646
libstdc++-v3/include/precompiled/stdc++.h
libstdc++-v3/testsuite/18_support/headers/ciso646/macros.cc [new file with mode: 0644]
libstdc++-v3/testsuite/18_support/headers/ciso646/macros.h.cc [new file with mode: 0644]
libstdc++-v3/testsuite/18_support/headers/cstdalign/macros.cc
libstdc++-v3/testsuite/18_support/headers/cstdalign/macros.h.cc [new file with mode: 0644]
libstdc++-v3/testsuite/18_support/headers/cstdalign/std_c++0x_neg.cc [deleted file]
libstdc++-v3/testsuite/18_support/headers/cstdbool/macros.cc
libstdc++-v3/testsuite/18_support/headers/cstdbool/macros.h.cc [new file with mode: 0644]
libstdc++-v3/testsuite/18_support/headers/cstdbool/std_c++0x_neg.cc [deleted file]
libstdc++-v3/testsuite/26_numerics/headers/ccomplex/complex.cc [new file with mode: 0644]
libstdc++-v3/testsuite/26_numerics/headers/ccomplex/complex.h.cc [new file with mode: 0644]
libstdc++-v3/testsuite/26_numerics/headers/ccomplex/std_c++0x_neg.cc [deleted file]
libstdc++-v3/testsuite/26_numerics/headers/ctgmath/complex.cc
libstdc++-v3/testsuite/26_numerics/headers/ctgmath/complex.h.cc [new file with mode: 0644]
libstdc++-v3/testsuite/26_numerics/headers/ctgmath/std_c++0x_neg.cc [deleted file]
libstdc++-v3/testsuite/27_io/objects/char/1.cc
libstdc++-v3/testsuite/27_io/objects/wchar_t/1.cc

index 5d37e94082f7792c5b3ccf07757e19ace95ffcbb..90a1a7dc8f9622b516202c5592edfb4cf903f5ab 100644 (file)
@@ -12,7 +12,9 @@
 #include <cctype>
 #include <cerrno>
 #include <cfloat>
+#if __cplusplus < 201703L
 #include <ciso646>
+#endif
 #include <climits>
 #include <clocale>
 #include <cmath>
index 799f6eae2a23904a7d8ac59eade0f31091e50fda..2ccfc07b83e5a871ebf2c648ffdb30c6561cfdad 100644 (file)
@@ -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">&lt;ccomplex&gt;</code>,
+<code class="filename">&lt;ciso646&gt;</code>,
+<code class="filename">&lt;cstdalign&gt;</code>,
+<code class="filename">&lt;cstdbool&gt;</code>, and
+<code class="filename">&lt;ctgmath&gt;</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
index 75cf948a4a2d9d082fac63f6956428fa89a97457..6b134de0e71fcfdbf06c718fa57bc65197bee0ab 100644 (file)
@@ -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">&lt;ccomplex&gt;</filename>,
+<filename class="headerfile">&lt;ciso646&gt;</filename>,
+<filename class="headerfile">&lt;cstdalign&gt;</filename>,
+<filename class="headerfile">&lt;cstdbool&gt;</filename>, and
+<filename class="headerfile">&lt;ctgmath&gt;</filename>.
+</para>
+
 </section>
 
 </section>
index a3102d9fce30becaf57a07bfc4f33ee9ed6b96b4..461ff2117b10deaa61ffef795e9765a32ebb75f1 100644 (file)
@@ -32,7 +32,9 @@
 #include <bits/c++config.h>
 
 #if __cplusplus >= 201103L
-# include <ccomplex>
+extern "C++" {
+#include <complex>
+}
 #endif
 
 #if __cplusplus >= 201103L && defined(__STRICT_ANSI__)
index aadddd91b606476a7d14d141524f1cc837790c22..6bf6727a15c4ab80620ad68ed6c9acac2b081048 100644 (file)
 #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
index ee1166aaecbea181c5b78e49baddc281fc95c3d1..5e47ddd68ccb51ffa8ae72d5615ac8b0f2060c6c 100644 (file)
@@ -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> instead"
+#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> instead"
+#  pragma GCC diagnostic pop
+#endif
+
 #endif
index 6e26f9be12eb74880e4758976c23f641b22a7457..98ad56b12e0ff415486748998595a06a2a27e5f9 100644 (file)
 
 #include <bits/c++config.h>
 
+#if __cplusplus >= 202002L && ! _GLIBCXX_USE_DEPRECATED
+#  error "<ciso646> is not a standard header in C++20, use <version> to detect implementation-specific macros"
+#elif __cplusplus >= 201703L && defined __DEPRECATED
+#  pragma GCC diagnostic push
+#  pragma GCC diagnostic ignored "-Wc++23-extensions"
+#  warning "<ciso646> is deprecated in C++17, use <version> to detect implementation-specific macros"
+#  pragma GCC diagnostic pop
+#endif
+
 #endif
index 4f6105884258aba88ff567d27d37686a1ded01a5..d356c9d80a350c98503c681f472daee965822adb 100644 (file)
 #  if _GLIBCXX_HAVE_STDALIGN_H
 #    include <stdalign.h>
 #  endif
+#  if __cplusplus >= 202002L && ! _GLIBCXX_USE_DEPRECATED
+#    error "<cstdalign> is not a standard header in C++20, remove the #include"
+#  elif __cplusplus >= 201703L && defined __DEPRECATED
+#    pragma GCC diagnostic push
+#    pragma GCC diagnostic ignored "-Wc++23-extensions"
+#    warning "<cstdalign> is deprecated in C++17, remove the #include"
+#    pragma GCC diagnostic pop
+#  endif
 #endif
 
 #endif
index 8d2e75df33f07476b105cb78dbe8f923d88f5e13..dde9df7120567f6fe2ff40e51e54873915eba4b9 100644 (file)
 #  if _GLIBCXX_HAVE_STDBOOL_H
 #    include <stdbool.h>
 #  endif
+#  if __cplusplus >= 202002L && ! _GLIBCXX_USE_DEPRECATED
+#    error "<cstdbool> is not a standard header in C++20, remove the #include"
+#  elif __cplusplus >= 201703L && defined __DEPRECATED
+#    pragma GCC diagnostic push
+#    pragma GCC diagnostic ignored "-Wc++23-extensions"
+#    warning "<cstdbool> is deprecated in C++17, remove the #include"
+#    pragma GCC diagnostic pop
+#  endif
 #endif
 
 #endif
index 39c17668f16a186d227bfa3d40264ce1a8bfc8c8..7bc230ec21b4828b9e6728de5f8e7a1c05106864 100644 (file)
 extern "C++" {
 #  include <complex>
 }
+#  if __cplusplus >= 202002L && ! _GLIBCXX_USE_DEPRECATED
+#    error "<ctgmath> is not a standard header in C++20, use <complex> or <cmath> instead"
+#  elif __cplusplus >= 201703L && defined __DEPRECATED
+#    pragma GCC diagnostic push
+#    pragma GCC diagnostic ignored "-Wc++23-extensions"
+#    warning "<ctgmath> is deprecated in C++17, use <complex> or <cmath> instead"
+#    pragma GCC diagnostic pop
+#  endif
 #endif
 
 #endif
index 7971f0d0c313697112facd0f4f8918bd3b50c29a..d0f7445fa44b8990c1464b3c567c547e2d977cad 100644 (file)
 #endif
 
 #include <bits/c++config.h>
+
+#if __cplusplus >= 202002L && ! _GLIBCXX_USE_DEPRECATED
+#  error "<ciso646> is not a standard header in C++20, use <version> to detect implementation-specific macros"
+#elif __cplusplus >= 201703L && defined __DEPRECATED
+#  pragma GCC diagnostic push
+#  pragma GCC diagnostic ignored "-Wc++23-extensions"
+#  warning "<ciso646> is deprecated in C++17, use <version> to detect implementation-specific macros"
+#  pragma GCC diagnostic pop
+#endif
+
 #endif
index 3eef20d16458db9e6b499984f37d3d0e4dc2c398..89917106bac2123910eda15f092a0fbbc3a56d6d 100644 (file)
@@ -34,7 +34,6 @@
 #endif
 #include <cctype>
 #include <cfloat>
-#include <ciso646>
 #include <climits>
 #include <csetjmp>
 #include <cstdarg>
@@ -43,6 +42,9 @@
 
 #if __cplusplus >= 201103L
 #include <cstdint>
+#if __cplusplus < 201703L
+#include <ciso646>
+#endif
 #endif
 
 // C++
 #include <cctype>
 #include <cerrno>
 #include <cfloat>
-#include <ciso646>
 #include <climits>
 #include <clocale>
 #include <cmath>
 #include <cwctype>
 
 #if __cplusplus >= 201103L
-#include <ccomplex>
 #include <cfenv>
 #include <cinttypes>
+#include <cstdint>
+#include <cuchar>
+#if __cplusplus < 201703L
+#include <ccomplex>
 #include <cstdalign>
 #include <cstdbool>
-#include <cstdint>
 #include <ctgmath>
-#include <cuchar>
+#endif
 #endif
 
 // C++
diff --git a/libstdc++-v3/testsuite/18_support/headers/ciso646/macros.cc b/libstdc++-v3/testsuite/18_support/headers/ciso646/macros.cc
new file mode 100644 (file)
index 0000000..ab3a041
--- /dev/null
@@ -0,0 +1,51 @@
+// { dg-options "-D_GLIBCXX_USE_DEPRECATED=0 -Wdeprecated -fno-operator-names" }
+// { dg-do preprocess }
+
+#include <ciso646>
+
+// { dg-warning "deprecated" "" { target c++17_only } 0 }
+// { dg-error "not a standard header" "" { target c++20 } 0 }
+
+#ifdef and
+# error "The header <ciso646> defines a macro named and"
+#endif
+
+#ifdef and_eq
+# error "The header <ciso646> defines a macro named and_eq"
+#endif
+
+#ifdef bitand
+# error "The header <ciso646> defines a macro named bitand"
+#endif
+
+#ifdef bitor
+# error "The header <ciso646> defines a macro named bitor"
+#endif
+
+#ifdef compl
+# error "The header <ciso646> defines a macro named compl"
+#endif
+
+#ifdef not
+# error "The header <ciso646> defines a macro named not"
+#endif
+
+#ifdef not_eq
+# error "The header <ciso646> defines a macro named not_eq"
+#endif
+
+#ifdef or
+# error "The header <ciso646> defines a macro named or"
+#endif
+
+#ifdef or_eq
+# error "The header <ciso646> defines a macro named or_eq"
+#endif
+
+#ifdef xor
+# error "The header <ciso646> defines a macro named xor"
+#endif
+
+#ifdef xor_eq
+# error "The header <ciso646> defines a macro named xor_eq"
+#endif
diff --git a/libstdc++-v3/testsuite/18_support/headers/ciso646/macros.h.cc b/libstdc++-v3/testsuite/18_support/headers/ciso646/macros.h.cc
new file mode 100644 (file)
index 0000000..a70c18d
--- /dev/null
@@ -0,0 +1,49 @@
+// { dg-options "-D_GLIBCXX_USE_DEPRECATED=0 -Wdeprecated -fno-operator-names" }
+// { dg-do preprocess }
+// { dg-bogus "deprecated" "C++17 deprecated <ciso646> but not <iso646.h>" }
+
+#include <iso646.h>
+
+#ifdef and
+# error "The header <iso646.h> defines a macro named and"
+#endif
+
+#ifdef and_eq
+# error "The header <iso646.h> defines a macro named and_eq"
+#endif
+
+#ifdef bitand
+# error "The header <iso646.h> defines a macro named bitand"
+#endif
+
+#ifdef bitor
+# error "The header <iso646.h> defines a macro named bitor"
+#endif
+
+#ifdef compl
+# error "The header <iso646.h> defines a macro named compl"
+#endif
+
+#ifdef not
+# error "The header <iso646.h> defines a macro named not"
+#endif
+
+#ifdef not_eq
+# error "The header <iso646.h> defines a macro named not_eq"
+#endif
+
+#ifdef or
+# error "The header <iso646.h> defines a macro named or"
+#endif
+
+#ifdef or_eq
+# error "The header <iso646.h> defines a macro named or_eq"
+#endif
+
+#ifdef xor
+# error "The header <iso646.h> defines a macro named xor"
+#endif
+
+#ifdef xor_eq
+# error "The header <iso646.h> defines a macro named xor_eq"
+#endif
index c50c921cd59a1ccfafc60debc1fb2c8e93ad3d73..793cd26dfa832586a729f15f654982074be45aef 100644 (file)
@@ -1,8 +1,13 @@
-// { dg-options "-D_GLIBCXX_USE_DEPRECATED=1 -Wno-deprecated" }
-// { dg-do preprocess { target c++11 } }
+// { dg-options "-D_GLIBCXX_USE_DEPRECATED=0 -Wdeprecated" }
+// { dg-do preprocess }
 
 #include <cstdalign>
 
+// { dg-error "ISO C.. 2011" "" { target c++98_only } 0 }
+// { dg-warning "deprecated" "" { target c++17_only } 0 }
+// { dg-error "not a standard header" "" { target c++20 } 0 }
+
+#if __cplusplus >= 201103L
 #ifndef __alignas_is_defined
 # error "The header <cstdalign> fails to define a macro named  __alignas_is_defined"
 #elif __alignas_is_defined != 1
@@ -22,3 +27,4 @@
 #ifdef alignof
 # error "The header <cstdalign> defines a macro named alignof"
 #endif
+#endif
diff --git a/libstdc++-v3/testsuite/18_support/headers/cstdalign/macros.h.cc b/libstdc++-v3/testsuite/18_support/headers/cstdalign/macros.h.cc
new file mode 100644 (file)
index 0000000..78f41ae
--- /dev/null
@@ -0,0 +1,25 @@
+// { dg-options "-D_GLIBCXX_USE_DEPRECATED=0 -Wdeprecated" }
+// { dg-do preprocess { target c++11 } }
+// { dg-bogus "deprecated" "C++17 deprecated <cstdalign> but not <stdalign.h>" }
+
+#include <stdalign.h>
+
+#ifndef __alignas_is_defined
+# error "The header <stdalign.h> fails to define a macro named  __alignas_is_defined"
+#elif __alignas_is_defined != 1
+# error "__alignas_is_defined is not defined to 1 in <stdalign.h>"
+#endif
+
+#ifndef __alignof_is_defined
+# error "The header <stdalign.h> fails to define a macro named __alignof_is_defined"
+#elif __alignof_is_defined != 1
+# error "__alignof_is_defined is not defined to 1 in <stdalign.h>"
+#endif
+
+#ifdef alignas
+# error "The header <stdalign.h> defines a macro named alignas"
+#endif
+
+#ifdef alignof
+# error "The header <stdalign.h> defines a macro named alignof"
+#endif
diff --git a/libstdc++-v3/testsuite/18_support/headers/cstdalign/std_c++0x_neg.cc b/libstdc++-v3/testsuite/18_support/headers/cstdalign/std_c++0x_neg.cc
deleted file mode 100644 (file)
index 14694f0..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-// { dg-options "-std=gnu++98" }
-// { dg-do compile { target c++98_only } }
-
-// Copyright (C) 2011-2024 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library.  This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <cstdalign>
-
-// { dg-error "ISO C.. 2011" "" { target *-*-* } 32 }
-
index e0afc26e458d5dee77f4be972453a683c90a18c5..658a02a4565bd2d265ac3c6116ae08bcde7b2ee9 100644 (file)
@@ -1,4 +1,5 @@
-// { dg-do compile { target c++11 } }
+// { dg-options "-D_GLIBCXX_USE_DEPRECATED=0 -Wdeprecated" }
+// { dg-do preprocess }
 
 // Copyright (C) 2012-2024 Free Software Foundation, Inc.
 //
 
 #include <cstdbool>
 
+// { dg-error "ISO C.. 2011" "" { target c++98_only } 0 }
+// { dg-warning "deprecated" "" { target c++17_only } 0 }
+// { dg-error "not a standard header" "" { target c++20 } 0 }
+
+#if __cplusplus >= 201103L
 #ifndef __bool_true_false_are_defined
 # error "The header <cstdbool> fails to define a macro named __bool_true_false_are_defined"
 #endif
@@ -34,3 +40,4 @@
 #ifdef false
 # error "The header <cstdbool> defines a macro named false"
 #endif
+#endif
diff --git a/libstdc++-v3/testsuite/18_support/headers/cstdbool/macros.h.cc b/libstdc++-v3/testsuite/18_support/headers/cstdbool/macros.h.cc
new file mode 100644 (file)
index 0000000..a3c0f9a
--- /dev/null
@@ -0,0 +1,21 @@
+// { dg-options "-D_GLIBCXX_USE_DEPRECATED=0 -Wdeprecated" }
+// { dg-do preprocess { target c++11 } }
+// { dg-bogus "deprecated" "C++17 deprecated <cstdbool> but not <stdbool.h>" }
+
+#include <stdbool.h>
+
+#ifndef __bool_true_false_are_defined
+# error "The header <stdbool.h> fails to define a macro named __bool_true_false_are_defined"
+#endif
+
+#ifdef bool
+# error "The header <stdbool.h> defines a macro named bool"
+#endif
+
+#ifdef true
+# error "The header <stdbool.h> defines a macro named true"
+#endif
+
+#ifdef false
+# error "The header <stdbool.h> defines a macro named false"
+#endif
diff --git a/libstdc++-v3/testsuite/18_support/headers/cstdbool/std_c++0x_neg.cc b/libstdc++-v3/testsuite/18_support/headers/cstdbool/std_c++0x_neg.cc
deleted file mode 100644 (file)
index 5b8c568..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-// { dg-options "-std=gnu++98" }
-// { dg-do compile { target c++98_only } }
-
-// Copyright (C) 2007-2024 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library.  This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <cstdbool>
-
-// { dg-error "ISO C.. 2011" "" { target *-*-* } 32 }
-
-
-
diff --git a/libstdc++-v3/testsuite/26_numerics/headers/ccomplex/complex.cc b/libstdc++-v3/testsuite/26_numerics/headers/ccomplex/complex.cc
new file mode 100644 (file)
index 0000000..d6c3378
--- /dev/null
@@ -0,0 +1,10 @@
+// { dg-options "-D_GLIBCXX_USE_DEPRECATED=0 -Wdeprecated" }
+// { dg-do compile }
+
+#include <ccomplex>
+
+std::complex<double> d;
+
+// { dg-error "ISO C.. 2011" "" { target c++98_only } 0 }
+// { dg-warning "deprecated" "" { target c++17_only } 0 }
+// { dg-error "not a standard header" "" { target c++20 } 0 }
diff --git a/libstdc++-v3/testsuite/26_numerics/headers/ccomplex/complex.h.cc b/libstdc++-v3/testsuite/26_numerics/headers/ccomplex/complex.h.cc
new file mode 100644 (file)
index 0000000..318b78e
--- /dev/null
@@ -0,0 +1,10 @@
+// { dg-options "-D_GLIBCXX_USE_DEPRECATED=0 -Wdeprecated" }
+// { dg-do compile }
+// { dg-bogus "deprecated" "C++17 deprecated <ccomplex> but not <complex.h>" }
+
+#include <complex.h>
+
+#if __cplusplus < 201103L
+# undef complex
+#endif
+std::complex<double> d; // { dg-error "does not name a template" "" { target c++98_only } 0 }
diff --git a/libstdc++-v3/testsuite/26_numerics/headers/ccomplex/std_c++0x_neg.cc b/libstdc++-v3/testsuite/26_numerics/headers/ccomplex/std_c++0x_neg.cc
deleted file mode 100644 (file)
index 16c623b..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-// { dg-options "-std=gnu++98" }
-// { dg-do compile { target c++98_only } }
-
-// Copyright (C) 2007-2024 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library.  This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <ccomplex>
-
-// { dg-error "ISO C.. 2011" "" { target *-*-* } 32 }
-
-
-
index a2c4a55c89b685d4c57f165dfa24b451866dab68..ef2bbd0e20a2b495c2cc1f9eaf52a496461b3dac 100644 (file)
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
-// { dg-do compile { target c++11 } }
+// { dg-options "-D_GLIBCXX_USE_DEPRECATED=0 -Wdeprecated" }
+// { dg-do compile }
 
 #include <ctgmath>
 
-std::complex<double> d;
+std::complex<double> d; // { dg-error "does not name a template" "" { target c++98_only } 0 }
+
+// { dg-error "ISO C.. 2011" "" { target c++98_only } 0 }
+// { dg-warning "deprecated" "" { target c++17_only } 0 }
+// { dg-error "not a standard header" "" { target c++20 } 0 }
diff --git a/libstdc++-v3/testsuite/26_numerics/headers/ctgmath/complex.h.cc b/libstdc++-v3/testsuite/26_numerics/headers/ctgmath/complex.h.cc
new file mode 100644 (file)
index 0000000..fd6847b
--- /dev/null
@@ -0,0 +1,10 @@
+// { dg-options "-D_GLIBCXX_USE_DEPRECATED=0 -Wdeprecated" }
+// { dg-do compile }
+// { dg-bogus "deprecated" "C++17 deprecated <ctgmath> but not <tgmath.h>" }
+
+#include <tgmath.h>
+
+#if __cplusplus < 201103L
+# undef complex
+#endif
+std::complex<double> d; // { dg-error "does not name a template" "" { target c++98_only } 0 }
diff --git a/libstdc++-v3/testsuite/26_numerics/headers/ctgmath/std_c++0x_neg.cc b/libstdc++-v3/testsuite/26_numerics/headers/ctgmath/std_c++0x_neg.cc
deleted file mode 100644 (file)
index d693c8b..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-// { dg-options "-std=gnu++98" }
-// { dg-do compile { target c++98_only } }
-
-// Copyright (C) 2007-2024 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library.  This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// <http://www.gnu.org/licenses/>.
-
-#include <ctgmath>
-
-// { dg-error "ISO C.. 2011" "" { target *-*-* } 32 }
-
-
-
index 9fc9244baf4794a4a070bfbfbe64b302977788b0..d50b38847027aae5853563aa625ec2b36d53c7ba 100644 (file)
@@ -53,7 +53,6 @@
 #include <cctype>
 #include <cerrno>
 #include <cfloat>
-#include <ciso646>
 #include <climits>
 #include <clocale>
 #include <cmath>
index 23b2168805d16ca08167c07c04d8274dff4e323b..c2f3643b4e5557a498a6bd072d48282735cc1b62 100644 (file)
@@ -53,7 +53,6 @@
 #include <cctype>
 #include <cerrno>
 #include <cfloat>
-#include <ciso646>
 #include <climits>
 #include <clocale>
 #include <cmath>