diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2024-10-23 16:01:50 +0100 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2024-11-06 12:47:19 +0000 |
commit | 5c34f02ba7ebe0dfec5595ebc8298c47d5f65e6e (patch) | |
tree | eed00b749404d0294fae0ed9a9e7b3f229a1e61f /libstdc++-v3/testsuite | |
parent | 6a050a3e650c7718c0a8cc948cd57706795f9805 (diff) | |
download | gcc-5c34f02ba7ebe0dfec5595ebc8298c47d5f65e6e.zip gcc-5c34f02ba7ebe0dfec5595ebc8298c47d5f65e6e.tar.gz gcc-5c34f02ba7ebe0dfec5595ebc8298c47d5f65e6e.tar.bz2 |
libstdc++: Deprecate useless <cxxx> compatibility headers for C++17
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.
Diffstat (limited to 'libstdc++-v3/testsuite')
16 files changed, 199 insertions, 109 deletions
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 index 0000000..ab3a041 --- /dev/null +++ b/libstdc++-v3/testsuite/18_support/headers/ciso646/macros.cc @@ -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 index 0000000..a70c18de --- /dev/null +++ b/libstdc++-v3/testsuite/18_support/headers/ciso646/macros.h.cc @@ -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 diff --git a/libstdc++-v3/testsuite/18_support/headers/cstdalign/macros.cc b/libstdc++-v3/testsuite/18_support/headers/cstdalign/macros.cc index c50c921..793cd26 100644 --- a/libstdc++-v3/testsuite/18_support/headers/cstdalign/macros.cc +++ b/libstdc++-v3/testsuite/18_support/headers/cstdalign/macros.cc @@ -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 index 0000000..78f41ae --- /dev/null +++ b/libstdc++-v3/testsuite/18_support/headers/cstdalign/macros.h.cc @@ -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 index 14694f0..0000000 --- a/libstdc++-v3/testsuite/18_support/headers/cstdalign/std_c++0x_neg.cc +++ /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 } - diff --git a/libstdc++-v3/testsuite/18_support/headers/cstdbool/macros.cc b/libstdc++-v3/testsuite/18_support/headers/cstdbool/macros.cc index e0afc26e..658a02a 100644 --- a/libstdc++-v3/testsuite/18_support/headers/cstdbool/macros.cc +++ b/libstdc++-v3/testsuite/18_support/headers/cstdbool/macros.cc @@ -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. // @@ -19,6 +20,11 @@ #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 index 0000000..a3c0f9a --- /dev/null +++ b/libstdc++-v3/testsuite/18_support/headers/cstdbool/macros.h.cc @@ -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 index 5b8c568..0000000 --- a/libstdc++-v3/testsuite/18_support/headers/cstdbool/std_c++0x_neg.cc +++ /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 index 0000000..d6c3378 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/ccomplex/complex.cc @@ -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 index 0000000..318b78e --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/ccomplex/complex.h.cc @@ -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 index 16c623b..0000000 --- a/libstdc++-v3/testsuite/26_numerics/headers/ccomplex/std_c++0x_neg.cc +++ /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 } - - - diff --git a/libstdc++-v3/testsuite/26_numerics/headers/ctgmath/complex.cc b/libstdc++-v3/testsuite/26_numerics/headers/ctgmath/complex.cc index a2c4a55..ef2bbd0 100644 --- a/libstdc++-v3/testsuite/26_numerics/headers/ctgmath/complex.cc +++ b/libstdc++-v3/testsuite/26_numerics/headers/ctgmath/complex.cc @@ -15,8 +15,13 @@ // 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 index 0000000..fd6847b --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/headers/ctgmath/complex.h.cc @@ -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 index d693c8b..0000000 --- a/libstdc++-v3/testsuite/26_numerics/headers/ctgmath/std_c++0x_neg.cc +++ /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 } - - - diff --git a/libstdc++-v3/testsuite/27_io/objects/char/1.cc b/libstdc++-v3/testsuite/27_io/objects/char/1.cc index 9fc9244..d50b388 100644 --- a/libstdc++-v3/testsuite/27_io/objects/char/1.cc +++ b/libstdc++-v3/testsuite/27_io/objects/char/1.cc @@ -53,7 +53,6 @@ #include <cctype> #include <cerrno> #include <cfloat> -#include <ciso646> #include <climits> #include <clocale> #include <cmath> diff --git a/libstdc++-v3/testsuite/27_io/objects/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/objects/wchar_t/1.cc index 23b2168..c2f3643 100644 --- a/libstdc++-v3/testsuite/27_io/objects/wchar_t/1.cc +++ b/libstdc++-v3/testsuite/27_io/objects/wchar_t/1.cc @@ -53,7 +53,6 @@ #include <cctype> #include <cerrno> #include <cfloat> -#include <ciso646> #include <climits> #include <clocale> #include <cmath> |