From 7759a387e25c46fe0fe19044f1785d012a85c1f8 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Fri, 20 Oct 2017 16:14:29 +0100 Subject: [PATCH] PR libstdc++/79433 no #error for including headers with wrong -std Backport from mainline 2017-09-12 Jonathan Wakely PR libstdc++/79433 * doc/xml/manual/status_cxx2017.xml: Update feature-test macros. * doc/html/*: Regenerate. * include/Makefile.am: Remove . * include/Makefile.in: Regenerate. * include/bits/c++17_warning.h: Remove. * include/bits/string_view.tcc: Do not include for pre-C++17 modes. * include/std/any: Likewise. (__cpp_lib_any): Define. * include/std/mutex (__cpp_lib_scoped_lock): Adjust value as per new SD-6 draft. * include/std/numeric (__cpp_lib_gcd_lcm): Define as per new SD-6 draft. * include/std/optional: Do not include . (__cpp_lib_optional): Define. * include/std/shared_mutex: Do not include . * include/std/string_view: Do not include . (__cpp_lib_string_view): Define. * include/std/variant: Do not include . (__cpp_lib_variant): Define. * testsuite/20_util/optional/cons/value_neg.cc: Adjust dg-error line numbers. * testsuite/26_numerics/gcd/1.cc: Test for __cpp_lib_gcd_lcm. * testsuite/26_numerics/gcd/gcd_neg.cc: Adjust dg-error line numbers. * testsuite/26_numerics/lcm/1.cc: Test for __cpp_lib_gcd_lcm. * testsuite/26_numerics/lcm/lcm_neg.cc: Adjust dg-error line numbers. * testsuite/30_threads/scoped_lock/requirements/typedefs.cc: Adjust expected value of __cpp_lib_scoped_lock. From-SVN: r253943 --- libstdc++-v3/ChangeLog | 35 ++++++++++++++++++ .../doc/xml/manual/status_cxx2017.xml | 28 +++++++++----- libstdc++-v3/include/Makefile.am | 1 - libstdc++-v3/include/Makefile.in | 1 - libstdc++-v3/include/bits/c++17_warning.h | 37 ------------------- libstdc++-v3/include/bits/string_view.tcc | 4 +- libstdc++-v3/include/std/any | 6 +-- libstdc++-v3/include/std/mutex | 4 +- libstdc++-v3/include/std/numeric | 5 ++- libstdc++-v3/include/std/optional | 8 ++-- libstdc++-v3/include/std/shared_mutex | 6 +-- libstdc++-v3/include/std/string_view | 6 +-- libstdc++-v3/include/std/variant | 6 +-- .../20_util/optional/cons/value_neg.cc | 6 +-- libstdc++-v3/testsuite/26_numerics/gcd/1.cc | 4 +- .../testsuite/26_numerics/gcd/gcd_neg.cc | 8 ++-- libstdc++-v3/testsuite/26_numerics/lcm/1.cc | 4 +- .../testsuite/26_numerics/lcm/lcm_neg.cc | 8 ++-- .../scoped_lock/requirements/typedefs.cc | 2 +- 19 files changed, 93 insertions(+), 86 deletions(-) delete mode 100644 libstdc++-v3/include/bits/c++17_warning.h diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index ace07325932..3e31af97069 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,40 @@ 2017-10-20 Jonathan Wakely + Backport from mainline + 2017-09-12 Jonathan Wakely + + PR libstdc++/79433 + * doc/xml/manual/status_cxx2017.xml: Update feature-test macros. + * doc/html/*: Regenerate. + * include/Makefile.am: Remove . + * include/Makefile.in: Regenerate. + * include/bits/c++17_warning.h: Remove. + * include/bits/string_view.tcc: Do not include + for pre-C++17 modes. + * include/std/any: Likewise. + (__cpp_lib_any): Define. + * include/std/mutex (__cpp_lib_scoped_lock): Adjust value as per new + SD-6 draft. + * include/std/numeric (__cpp_lib_gcd_lcm): Define as per new SD-6 + draft. + * include/std/optional: Do not include . + (__cpp_lib_optional): Define. + * include/std/shared_mutex: Do not include . + * include/std/string_view: Do not include . + (__cpp_lib_string_view): Define. + * include/std/variant: Do not include . + (__cpp_lib_variant): Define. + * testsuite/20_util/optional/cons/value_neg.cc: Adjust dg-error line + numbers. + * testsuite/26_numerics/gcd/1.cc: Test for __cpp_lib_gcd_lcm. + * testsuite/26_numerics/gcd/gcd_neg.cc: Adjust dg-error line + numbers. + * testsuite/26_numerics/lcm/1.cc: Test for __cpp_lib_gcd_lcm. + * testsuite/26_numerics/lcm/lcm_neg.cc: Adjust dg-error line + numbers. + * testsuite/30_threads/scoped_lock/requirements/typedefs.cc: Adjust + expected value of __cpp_lib_scoped_lock. + Backport from mainline 2017-10-19 Jonathan Wakely diff --git a/libstdc++-v3/doc/xml/manual/status_cxx2017.xml b/libstdc++-v3/doc/xml/manual/status_cxx2017.xml index 05cf41c3489..6158f96105f 100644 --- a/libstdc++-v3/doc/xml/manual/status_cxx2017.xml +++ b/libstdc++-v3/doc/xml/manual/status_cxx2017.xml @@ -98,7 +98,9 @@ Feature-testing recommendations for C++. 7 - __has_include(<variant>) + __has_include(<variant>), + __cpp_lib_variant >= 201603 + @@ -109,7 +111,9 @@ Feature-testing recommendations for C++. 7 - __has_include(<optional>) + __has_include(<optional>), + __cpp_lib_optional >= 201603 + @@ -120,7 +124,9 @@ Feature-testing recommendations for C++. 7 - __has_include(<any>) + __has_include(<any>), + __cpp_lib_any >= 201603 + @@ -131,7 +137,9 @@ Feature-testing recommendations for C++. 7 - __has_include(<string_view>) + __has_include(<string_view>), + __cpp_lib_string_view >= 201603 + @@ -143,7 +151,9 @@ Feature-testing recommendations for C++. No - __has_include(<memory_resource>) + __has_include(<memory_resource>), + __cpp_lib_memory_resource >= 201603 + @@ -616,7 +626,9 @@ Feature-testing recommendations for C++. No __has_include(<execution>) , - __cpp_lib_parallel_algorithm >= 201603 + __cpp_lib_execution >= 201603 , + __cpp_lib_parallel_algorithm >= 201603 + @@ -638,9 +650,7 @@ Feature-testing recommendations for C++. 7 - __cpp_lib_gcd >= 201606 , - __cpp_lib_lcm >= 201606 - + __cpp_lib_gcd_lcm >= 201606 diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am index a6517365827..6395f1e6ae0 100644 --- a/libstdc++-v3/include/Makefile.am +++ b/libstdc++-v3/include/Makefile.am @@ -96,7 +96,6 @@ bits_headers = \ ${bits_srcdir}/boost_concept_check.h \ ${bits_srcdir}/c++0x_warning.h \ ${bits_srcdir}/c++14_warning.h \ - ${bits_srcdir}/c++17_warning.h \ ${bits_srcdir}/char_traits.h \ ${bits_srcdir}/codecvt.h \ ${bits_srcdir}/concept_check.h \ diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in index 783c647087f..745a8495da5 100644 --- a/libstdc++-v3/include/Makefile.in +++ b/libstdc++-v3/include/Makefile.in @@ -389,7 +389,6 @@ bits_headers = \ ${bits_srcdir}/boost_concept_check.h \ ${bits_srcdir}/c++0x_warning.h \ ${bits_srcdir}/c++14_warning.h \ - ${bits_srcdir}/c++17_warning.h \ ${bits_srcdir}/char_traits.h \ ${bits_srcdir}/codecvt.h \ ${bits_srcdir}/concept_check.h \ diff --git a/libstdc++-v3/include/bits/c++17_warning.h b/libstdc++-v3/include/bits/c++17_warning.h deleted file mode 100644 index 759fdc92250..00000000000 --- a/libstdc++-v3/include/bits/c++17_warning.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2016-2017 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. - -// Under Section 7 of GPL version 3, you are granted additional -// permissions described in the GCC Runtime Library Exception, version -// 3.1, as published by the Free Software Foundation. - -// You should have received a copy of the GNU General Public License and -// a copy of the GCC Runtime Library Exception along with this program; -// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -// . - -/** @file bits/c++17_warning.h - * This is an internal header file, included by other library headers. - * Do not attempt to use it directly. @headername{iosfwd} - */ - -#ifndef _CXX17_WARNING_H -#define _CXX17_WARNING_H 1 - -#if __cplusplus <= 201402L -#error This file requires compiler and library support \ -for the ISO C++ 2017 standard. This support must be enabled \ -with the -std=c++17 or -std=gnu++17 compiler options. -#endif - -#endif diff --git a/libstdc++-v3/include/bits/string_view.tcc b/libstdc++-v3/include/bits/string_view.tcc index accc54e87bb..86661ff09aa 100644 --- a/libstdc++-v3/include/bits/string_view.tcc +++ b/libstdc++-v3/include/bits/string_view.tcc @@ -36,9 +36,7 @@ #pragma GCC system_header -#if __cplusplus <= 201402L -# include -#else +#if __cplusplus >= 201703L namespace std _GLIBCXX_VISIBILITY(default) { diff --git a/libstdc++-v3/include/std/any b/libstdc++-v3/include/std/any index 1e84302f0c0..eef510535d7 100644 --- a/libstdc++-v3/include/std/any +++ b/libstdc++-v3/include/std/any @@ -31,9 +31,7 @@ #pragma GCC system_header -#if __cplusplus <= 201402L -# include -#else +#if __cplusplus >= 201703L #include #include @@ -68,6 +66,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif } +#define __cpp_lib_any 201603 + /** * @brief A type-safe container of any type. * diff --git a/libstdc++-v3/include/std/mutex b/libstdc++-v3/include/std/mutex index d7778826c9d..6d5649e6565 100644 --- a/libstdc++-v3/include/std/mutex +++ b/libstdc++-v3/include/std/mutex @@ -556,8 +556,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } } -#if __cplusplus > 201402L -#define __cpp_lib_scoped_lock 201707 +#if __cplusplus >= 201703L +#define __cpp_lib_scoped_lock 201703 /** @brief A scoped lock type for multiple lockable objects. * * A scoped_lock controls mutex ownership within a scope, releasing diff --git a/libstdc++-v3/include/std/numeric b/libstdc++-v3/include/std/numeric index c7abbc1b681..2b222374181 100644 --- a/libstdc++-v3/include/std/numeric +++ b/libstdc++-v3/include/std/numeric @@ -125,7 +125,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus > 201402L +#define __cpp_lib_gcd_lcm 201606 +// These were used in drafts of SD-6: #define __cpp_lib_gcd 201606 +#define __cpp_lib_lcm 201606 + /// Greatest common divisor template constexpr common_type_t<_Mn, _Nn> @@ -138,7 +142,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return __detail::__gcd(__m, __n); } -#define __cpp_lib_lcm 201606 /// Least common multiple template constexpr common_type_t<_Mn, _Nn> diff --git a/libstdc++-v3/include/std/optional b/libstdc++-v3/include/std/optional index c28f20bcc56..9e3f1f75fcd 100644 --- a/libstdc++-v3/include/std/optional +++ b/libstdc++-v3/include/std/optional @@ -29,9 +29,9 @@ #ifndef _GLIBCXX_OPTIONAL #define _GLIBCXX_OPTIONAL 1 -#if __cplusplus <= 201402L -# include -#else +#pragma GCC system_header + +#if __cplusplus >= 201703L #include #include @@ -51,6 +51,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * @{ */ +#define __cpp_lib_optional 201603 + template class optional; diff --git a/libstdc++-v3/include/std/shared_mutex b/libstdc++-v3/include/std/shared_mutex index ff116c0e30d..295fdc7118c 100644 --- a/libstdc++-v3/include/std/shared_mutex +++ b/libstdc++-v3/include/std/shared_mutex @@ -31,9 +31,7 @@ #pragma GCC system_header -#if __cplusplus <= 201103L -# include -#else +#if __cplusplus >= 201402L #include #include @@ -51,7 +49,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #ifdef _GLIBCXX_USE_C99_STDINT_TR1 #ifdef _GLIBCXX_HAS_GTHREADS -#if __cplusplus > 201402L +#if __cplusplus >= 201703L #define __cpp_lib_shared_mutex 201505 class shared_mutex; #endif diff --git a/libstdc++-v3/include/std/string_view b/libstdc++-v3/include/std/string_view index 6c7cb035f9a..8bbf9afc7c6 100644 --- a/libstdc++-v3/include/std/string_view +++ b/libstdc++-v3/include/std/string_view @@ -35,9 +35,7 @@ #pragma GCC system_header -#if __cplusplus <= 201402L -# include -#else +#if __cplusplus >= 201703L #include #include @@ -49,6 +47,8 @@ namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION +#define __cpp_lib_string_view 201603 + /** * @class basic_string_view * @brief A non-owning reference to a string. diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant index c822953ecb1..1f1a8492323 100644 --- a/libstdc++-v3/include/std/variant +++ b/libstdc++-v3/include/std/variant @@ -31,9 +31,7 @@ #pragma GCC system_header -#if __cplusplus <= 201402L -# include -#else +#if __cplusplus >= 201703L #include #include @@ -73,6 +71,8 @@ _GLIBCXX_END_NAMESPACE_VERSION _GLIBCXX_BEGIN_NAMESPACE_VERSION +#define __cpp_lib_variant 201603 + template class tuple; template class variant; template struct hash; diff --git a/libstdc++-v3/testsuite/20_util/optional/cons/value_neg.cc b/libstdc++-v3/testsuite/20_util/optional/cons/value_neg.cc index 87907f96d13..7af39038692 100644 --- a/libstdc++-v3/testsuite/20_util/optional/cons/value_neg.cc +++ b/libstdc++-v3/testsuite/20_util/optional/cons/value_neg.cc @@ -37,8 +37,8 @@ int main() std::optional> oup2 = new int; // { dg-error "conversion" } struct U { explicit U(std::in_place_t); }; std::optional ou(std::in_place); // { dg-error "no matching" } - // { dg-error "no type" "" { target { *-*-* } } 488 } - // { dg-error "no type" "" { target { *-*-* } } 498 } - // { dg-error "no type" "" { target { *-*-* } } 555 } + // { dg-error "no type" "" { target { *-*-* } } 490 } + // { dg-error "no type" "" { target { *-*-* } } 500 } + // { dg-error "no type" "" { target { *-*-* } } 557 } } } diff --git a/libstdc++-v3/testsuite/26_numerics/gcd/1.cc b/libstdc++-v3/testsuite/26_numerics/gcd/1.cc index 17e97a7e0ae..0f0b7b85b4e 100644 --- a/libstdc++-v3/testsuite/26_numerics/gcd/1.cc +++ b/libstdc++-v3/testsuite/26_numerics/gcd/1.cc @@ -20,9 +20,9 @@ #include -#ifndef __cpp_lib_gcd +#ifndef __cpp_lib_gcd_lcm # error "Feature-test macro for gcd missing" -#elif __cpp_lib_gcd != 201606 +#elif __cpp_lib_gcd_lcm != 201606 # error "Feature-test macro for gcd has wrong value" #endif diff --git a/libstdc++-v3/testsuite/26_numerics/gcd/gcd_neg.cc b/libstdc++-v3/testsuite/26_numerics/gcd/gcd_neg.cc index d88f145d754..0fda1aad906 100644 --- a/libstdc++-v3/testsuite/26_numerics/gcd/gcd_neg.cc +++ b/libstdc++-v3/testsuite/26_numerics/gcd/gcd_neg.cc @@ -31,9 +31,9 @@ test01() std::gcd(0.1, 0.1); // { dg-error "from here" } } -// { dg-error "integers" "" { target *-*-* } 134 } -// { dg-error "integers" "" { target *-*-* } 135 } -// { dg-error "not bools" "" { target *-*-* } 136 } -// { dg-error "not bools" "" { target *-*-* } 137 } +// { dg-error "integers" "" { target *-*-* } 138 } +// { dg-error "integers" "" { target *-*-* } 139 } +// { dg-error "not bools" "" { target *-*-* } 140 } +// { dg-error "not bools" "" { target *-*-* } 141 } // { dg-prune-output "deleted function" } // { dg-prune-output "invalid operands" } diff --git a/libstdc++-v3/testsuite/26_numerics/lcm/1.cc b/libstdc++-v3/testsuite/26_numerics/lcm/1.cc index 81cb91437ba..367f0a3e0e3 100644 --- a/libstdc++-v3/testsuite/26_numerics/lcm/1.cc +++ b/libstdc++-v3/testsuite/26_numerics/lcm/1.cc @@ -20,9 +20,9 @@ #include -#ifndef __cpp_lib_lcm +#ifndef __cpp_lib_gcd_lcm # error "Feature-test macro for lcm missing" -#elif __cpp_lib_lcm != 201606 +#elif __cpp_lib_gcd_lcm != 201606 # error "Feature-test macro for lcm has wrong value" #endif diff --git a/libstdc++-v3/testsuite/26_numerics/lcm/lcm_neg.cc b/libstdc++-v3/testsuite/26_numerics/lcm/lcm_neg.cc index f2d82894531..b1c42803f42 100644 --- a/libstdc++-v3/testsuite/26_numerics/lcm/lcm_neg.cc +++ b/libstdc++-v3/testsuite/26_numerics/lcm/lcm_neg.cc @@ -31,9 +31,9 @@ test01() std::lcm(0.1, 0.1); // { dg-error "from here" } } -// { dg-error "integers" "" { target *-*-* } 147 } -// { dg-error "integers" "" { target *-*-* } 148 } -// { dg-error "not bools" "" { target *-*-* } 149 } -// { dg-error "not bools" "" { target *-*-* } 150 } +// { dg-error "integers" "" { target *-*-* } 150 } +// { dg-error "integers" "" { target *-*-* } 151 } +// { dg-error "not bools" "" { target *-*-* } 152 } +// { dg-error "not bools" "" { target *-*-* } 153 } // { dg-prune-output "deleted function" } // { dg-prune-output "invalid operands" } diff --git a/libstdc++-v3/testsuite/30_threads/scoped_lock/requirements/typedefs.cc b/libstdc++-v3/testsuite/30_threads/scoped_lock/requirements/typedefs.cc index 0a8903ebaab..b8a09042094 100644 --- a/libstdc++-v3/testsuite/30_threads/scoped_lock/requirements/typedefs.cc +++ b/libstdc++-v3/testsuite/30_threads/scoped_lock/requirements/typedefs.cc @@ -27,7 +27,7 @@ #ifndef __cpp_lib_scoped_lock # error "Feature-test macro for scoped_lock missing" -#elif __cpp_lib_scoped_lock != 201707 +#elif __cpp_lib_scoped_lock != 201703 # error "Feature-test macro for scoped_lock has wrong value" #endif