From: Jonathan Wakely Date: Wed, 23 Oct 2024 15:01:50 +0000 (+0100) Subject: libstdc++: Deprecate useless compatibility headers for C++17 X-Git-Tag: basepoints/gcc-16~4572 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=r15-4981-g5c34f02ba7e;p=thirdparty%2Fgcc.git libstdc++: Deprecate useless compatibility headers for C++17 These headers make no sense for C++ programs, because they either define different content to the corresponding 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 , 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 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 directly instead of . * include/c_compatibility/tgmath.h: Include and directly, instead of . * 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 . * 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. --- diff --git a/gcc/testsuite/g++.old-deja/g++.other/headers1.C b/gcc/testsuite/g++.old-deja/g++.other/headers1.C index 5d37e94082f7..90a1a7dc8f96 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 #include #include +#if __cplusplus < 201703L #include +#endif #include #include #include diff --git a/libstdc++-v3/doc/html/manual/api.html b/libstdc++-v3/doc/html/manual/api.html index 799f6eae2a23..2ccfc07b83e5 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 std::basic_istream. longer allowed in C++20 mode.

15

Enabled debug assertions by default for unoptimized builds. +

+Added warnings when including the headers that were deprecated in C++17 +and removed in C++20: +<ccomplex>, +<ciso646>, +<cstdalign>, +<cstdbool>, and +<ctgmath>.

\ 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 75cf948a4a2d..6b134de0e71f 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 std::basic_istream. Enabled debug assertions by default for unoptimized builds. + +Added warnings when including the headers that were deprecated in C++17 +and removed in C++20: +<ccomplex>, +<ciso646>, +<cstdalign>, +<cstdbool>, and +<ctgmath>. + + diff --git a/libstdc++-v3/include/c_compatibility/complex.h b/libstdc++-v3/include/c_compatibility/complex.h index a3102d9fce30..461ff2117b10 100644 --- a/libstdc++-v3/include/c_compatibility/complex.h +++ b/libstdc++-v3/include/c_compatibility/complex.h @@ -32,7 +32,9 @@ #include #if __cplusplus >= 201103L -# include +extern "C++" { +#include +} #endif #if __cplusplus >= 201103L && defined(__STRICT_ANSI__) diff --git a/libstdc++-v3/include/c_compatibility/tgmath.h b/libstdc++-v3/include/c_compatibility/tgmath.h index aadddd91b606..6bf6727a15c4 100644 --- a/libstdc++-v3/include/c_compatibility/tgmath.h +++ b/libstdc++-v3/include/c_compatibility/tgmath.h @@ -32,11 +32,12 @@ #include #if __cplusplus >= 201103L -# include -#else -# if _GLIBCXX_HAVE_TGMATH_H -# include_next -# endif +# include +extern "C++" { +# include +} +#elif _GLIBCXX_HAVE_TGMATH_H +# include_next #endif #endif diff --git a/libstdc++-v3/include/c_global/ccomplex b/libstdc++-v3/include/c_global/ccomplex index ee1166aaecbe..5e47ddd68ccb 100644 --- a/libstdc++-v3/include/c_global/ccomplex +++ b/libstdc++-v3/include/c_global/ccomplex @@ -41,4 +41,13 @@ extern "C++" { #include } +#if __cplusplus >= 202002L && ! _GLIBCXX_USE_DEPRECATED +# error " is not a standard header in C++20, use instead" +#elif __cplusplus >= 201703L && defined __DEPRECATED +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wc++23-extensions" +# warning " is deprecated in C++17, use instead" +# pragma GCC diagnostic pop +#endif + #endif diff --git a/libstdc++-v3/include/c_global/ciso646 b/libstdc++-v3/include/c_global/ciso646 index 6e26f9be12eb..98ad56b12e0f 100644 --- a/libstdc++-v3/include/c_global/ciso646 +++ b/libstdc++-v3/include/c_global/ciso646 @@ -38,4 +38,13 @@ #include +#if __cplusplus >= 202002L && ! _GLIBCXX_USE_DEPRECATED +# error " is not a standard header in C++20, use to detect implementation-specific macros" +#elif __cplusplus >= 201703L && defined __DEPRECATED +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wc++23-extensions" +# warning " is deprecated in C++17, use to detect implementation-specific macros" +# pragma GCC diagnostic pop +#endif + #endif diff --git a/libstdc++-v3/include/c_global/cstdalign b/libstdc++-v3/include/c_global/cstdalign index 4f6105884258..d356c9d80a35 100644 --- a/libstdc++-v3/include/c_global/cstdalign +++ b/libstdc++-v3/include/c_global/cstdalign @@ -40,6 +40,14 @@ # if _GLIBCXX_HAVE_STDALIGN_H # include # endif +# if __cplusplus >= 202002L && ! _GLIBCXX_USE_DEPRECATED +# error " 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 " is deprecated in C++17, remove the #include" +# pragma GCC diagnostic pop +# endif #endif #endif diff --git a/libstdc++-v3/include/c_global/cstdbool b/libstdc++-v3/include/c_global/cstdbool index 8d2e75df33f0..dde9df712056 100644 --- a/libstdc++-v3/include/c_global/cstdbool +++ b/libstdc++-v3/include/c_global/cstdbool @@ -40,6 +40,14 @@ # if _GLIBCXX_HAVE_STDBOOL_H # include # endif +# if __cplusplus >= 202002L && ! _GLIBCXX_USE_DEPRECATED +# error " 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 " is deprecated in C++17, remove the #include" +# pragma GCC diagnostic pop +# endif #endif #endif diff --git a/libstdc++-v3/include/c_global/ctgmath b/libstdc++-v3/include/c_global/ctgmath index 39c17668f16a..7bc230ec21b4 100644 --- a/libstdc++-v3/include/c_global/ctgmath +++ b/libstdc++-v3/include/c_global/ctgmath @@ -40,6 +40,14 @@ extern "C++" { # include } +# if __cplusplus >= 202002L && ! _GLIBCXX_USE_DEPRECATED +# error " is not a standard header in C++20, use or instead" +# elif __cplusplus >= 201703L && defined __DEPRECATED +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wc++23-extensions" +# warning " is deprecated in C++17, use or instead" +# pragma GCC diagnostic pop +# endif #endif #endif diff --git a/libstdc++-v3/include/c_std/ciso646 b/libstdc++-v3/include/c_std/ciso646 index 7971f0d0c313..d0f7445fa44b 100644 --- a/libstdc++-v3/include/c_std/ciso646 +++ b/libstdc++-v3/include/c_std/ciso646 @@ -37,4 +37,14 @@ #endif #include + +#if __cplusplus >= 202002L && ! _GLIBCXX_USE_DEPRECATED +# error " is not a standard header in C++20, use to detect implementation-specific macros" +#elif __cplusplus >= 201703L && defined __DEPRECATED +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wc++23-extensions" +# warning " is deprecated in C++17, use to detect implementation-specific macros" +# pragma GCC diagnostic pop +#endif + #endif diff --git a/libstdc++-v3/include/precompiled/stdc++.h b/libstdc++-v3/include/precompiled/stdc++.h index 3eef20d16458..89917106bac2 100644 --- a/libstdc++-v3/include/precompiled/stdc++.h +++ b/libstdc++-v3/include/precompiled/stdc++.h @@ -34,7 +34,6 @@ #endif #include #include -#include #include #include #include @@ -43,6 +42,9 @@ #if __cplusplus >= 201103L #include +#if __cplusplus < 201703L +#include +#endif #endif // C++ @@ -108,7 +110,6 @@ #include #include #include -#include #include #include #include @@ -124,14 +125,16 @@ #include #if __cplusplus >= 201103L -#include #include #include +#include +#include +#if __cplusplus < 201703L +#include #include #include -#include #include -#include +#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 index 000000000000..ab3a041de062 --- /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 + +// { dg-warning "deprecated" "" { target c++17_only } 0 } +// { dg-error "not a standard header" "" { target c++20 } 0 } + +#ifdef and +# error "The header defines a macro named and" +#endif + +#ifdef and_eq +# error "The header defines a macro named and_eq" +#endif + +#ifdef bitand +# error "The header defines a macro named bitand" +#endif + +#ifdef bitor +# error "The header defines a macro named bitor" +#endif + +#ifdef compl +# error "The header defines a macro named compl" +#endif + +#ifdef not +# error "The header defines a macro named not" +#endif + +#ifdef not_eq +# error "The header defines a macro named not_eq" +#endif + +#ifdef or +# error "The header defines a macro named or" +#endif + +#ifdef or_eq +# error "The header defines a macro named or_eq" +#endif + +#ifdef xor +# error "The header defines a macro named xor" +#endif + +#ifdef xor_eq +# error "The header 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 000000000000..a70c18de918e --- /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 but not " } + +#include + +#ifdef and +# error "The header defines a macro named and" +#endif + +#ifdef and_eq +# error "The header defines a macro named and_eq" +#endif + +#ifdef bitand +# error "The header defines a macro named bitand" +#endif + +#ifdef bitor +# error "The header defines a macro named bitor" +#endif + +#ifdef compl +# error "The header defines a macro named compl" +#endif + +#ifdef not +# error "The header defines a macro named not" +#endif + +#ifdef not_eq +# error "The header defines a macro named not_eq" +#endif + +#ifdef or +# error "The header defines a macro named or" +#endif + +#ifdef or_eq +# error "The header defines a macro named or_eq" +#endif + +#ifdef xor +# error "The header defines a macro named xor" +#endif + +#ifdef xor_eq +# error "The header 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 c50c921cd59a..793cd26dfa83 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 +// { 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 fails to define a macro named __alignas_is_defined" #elif __alignas_is_defined != 1 @@ -22,3 +27,4 @@ #ifdef alignof # error "The header 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 000000000000..78f41ae02e85 --- /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 but not " } + +#include + +#ifndef __alignas_is_defined +# error "The header fails to define a macro named __alignas_is_defined" +#elif __alignas_is_defined != 1 +# error "__alignas_is_defined is not defined to 1 in " +#endif + +#ifndef __alignof_is_defined +# error "The header fails to define a macro named __alignof_is_defined" +#elif __alignof_is_defined != 1 +# error "__alignof_is_defined is not defined to 1 in " +#endif + +#ifdef alignas +# error "The header defines a macro named alignas" +#endif + +#ifdef alignof +# error "The header 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 14694f034e6c..000000000000 --- 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 -// . - -#include - -// { 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 e0afc26e458d..658a02a4565b 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 +// { 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 fails to define a macro named __bool_true_false_are_defined" #endif @@ -34,3 +40,4 @@ #ifdef false # error "The header 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 000000000000..a3c0f9a0aec0 --- /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 but not " } + +#include + +#ifndef __bool_true_false_are_defined +# error "The header fails to define a macro named __bool_true_false_are_defined" +#endif + +#ifdef bool +# error "The header defines a macro named bool" +#endif + +#ifdef true +# error "The header defines a macro named true" +#endif + +#ifdef false +# error "The header 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 5b8c56888775..000000000000 --- 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 -// . - -#include - -// { 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 000000000000..d6c33781ae5d --- /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 + +std::complex 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 000000000000..318b78ee89ee --- /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 but not " } + +#include + +#if __cplusplus < 201103L +# undef complex +#endif +std::complex 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 16c623b25b08..000000000000 --- 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 -// . - -#include - -// { 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 a2c4a55c89b6..ef2bbd0e20a2 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 // . -// { dg-do compile { target c++11 } } +// { dg-options "-D_GLIBCXX_USE_DEPRECATED=0 -Wdeprecated" } +// { dg-do compile } #include -std::complex d; +std::complex 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 000000000000..fd6847bff4fc --- /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 but not " } + +#include + +#if __cplusplus < 201103L +# undef complex +#endif +std::complex 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 d693c8b23ed1..000000000000 --- 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 -// . - -#include - -// { 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 9fc9244baf47..d50b38847027 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 #include #include -#include #include #include #include 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 23b2168805d1..c2f3643b4e55 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 #include #include -#include #include #include #include