From: Daniel Kruegler Date: Thu, 23 Mar 2017 19:40:07 +0000 (+0000) Subject: Implement P0607R0 "Inline Variables for Standard Library" for C++17 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=288695f7a49e187d9c4e0dad6024aed227512477;p=gcc.git Implement P0607R0 "Inline Variables for Standard Library" for C++17 2017-03-23 Daniel Kruegler * include/bits/c++config (_GLIBCXX17_INLINE): Define. * include/bits/regex_constants.h (All std::regex_constants constants): Add _GLIBCXX17_INLINE as per P0607R0. * include/bits/std_mutex.h (defer_lock, try_to_lock, adopt_lock): Likewise. * include/bits/stl_pair.h (piecewise_construct): Likewise. * include/bits/uses_allocator.h (allocator_arg, uses_allocator_v) (__is_uses_allocator_constructible_v) (__is_nothrow_uses_allocator_constructible_v): Likewise. * include/std/chrono (treat_as_floating_point_v): Likewise. * include/std/functional (is_bind_expression_v, is_placeholder_v): Likewise. * include/std/optional (nullopt): Likewise. * include/std/ratio (ratio_equal_v, ratio_not_equal_v, ratio_less_v) ratio_less_equal_v, ratio_greater_v, ratio_greater_equal_v): Likewise. * include/std/system_error (is_error_code_enum_v) (is_error_condition_enum_v): Likewise. * include/std/tuple (tuple_size_v, ignore): Likewise. (ignore): Declare ignore constexpr as per LWG 2773, declare assignment constexpr as per LWG 2933. * include/std/type_traits (All variable templates): Add _GLIBCXX17_INLINE as per P0607R0. * include/std/variant (variant_size_v, variant_npos, __index_of_v) (__tuple_count_v, __exactly_once): Likewise. * testsuite/18_support/headers/new/synopsis.cc (hardware_destructive_interference_size) (hardware_constructive_interference_size): Likewise for commented-out variables. * testsuite/20_util/tuple/creation_functions/constexpr.cc: Add new test function for constexpr std::ignore (LWG 2773). * testsuite/20_util/tuple/creation_functions/constexpr_cpp14.cc: New test for LWG 2933. From-SVN: r246423 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 56a80c7ce62..b3e3fe2ba56 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,38 @@ +2017-03-23 Daniel Kruegler + + * include/bits/c++config (_GLIBCXX17_INLINE): Define. + * include/bits/regex_constants.h (All std::regex_constants constants): + Add _GLIBCXX17_INLINE as per P0607R0. + * include/bits/std_mutex.h (defer_lock, try_to_lock, adopt_lock): + Likewise. + * include/bits/stl_pair.h (piecewise_construct): Likewise. + * include/bits/uses_allocator.h (allocator_arg, uses_allocator_v) + (__is_uses_allocator_constructible_v) + (__is_nothrow_uses_allocator_constructible_v): Likewise. + * include/std/chrono (treat_as_floating_point_v): Likewise. + * include/std/functional (is_bind_expression_v, is_placeholder_v): + Likewise. + * include/std/optional (nullopt): Likewise. + * include/std/ratio (ratio_equal_v, ratio_not_equal_v, ratio_less_v) + ratio_less_equal_v, ratio_greater_v, ratio_greater_equal_v): Likewise. + * include/std/system_error (is_error_code_enum_v) + (is_error_condition_enum_v): Likewise. + * include/std/tuple (tuple_size_v, ignore): Likewise. + (ignore): Declare ignore constexpr as per LWG 2773, declare assignment + constexpr as per LWG 2933. + * include/std/type_traits (All variable templates): Add + _GLIBCXX17_INLINE as per P0607R0. + * include/std/variant (variant_size_v, variant_npos, __index_of_v) + (__tuple_count_v, __exactly_once): Likewise. + * testsuite/18_support/headers/new/synopsis.cc + (hardware_destructive_interference_size) + (hardware_constructive_interference_size): Likewise for commented-out + variables. + * testsuite/20_util/tuple/creation_functions/constexpr.cc: Add new + test function for constexpr std::ignore (LWG 2773). + * testsuite/20_util/tuple/creation_functions/constexpr_cpp14.cc: New + test for LWG 2933. + 2017-03-22 Jonathan Wakely * include/bits/shared_ptr.h (shared_ptr, weak_ptr): Add deduction diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config index 3b694e07c51..8ca6b0345b1 100644 --- a/libstdc++-v3/include/bits/c++config +++ b/libstdc++-v3/include/bits/c++config @@ -122,6 +122,14 @@ # endif #endif +#ifndef _GLIBCXX17_INLINE +# if __cplusplus > 201402L +# define _GLIBCXX17_INLINE inline +# else +# define _GLIBCXX17_INLINE +# endif +#endif + // Macro for noexcept, to support in mixed 03/0x mode. #ifndef _GLIBCXX_NOEXCEPT # if __cplusplus >= 201103L diff --git a/libstdc++-v3/include/bits/regex_constants.h b/libstdc++-v3/include/bits/regex_constants.h index 741b7832cdc..dad2d637aa8 100644 --- a/libstdc++-v3/include/bits/regex_constants.h +++ b/libstdc++-v3/include/bits/regex_constants.h @@ -84,7 +84,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * Specifies that the matching of regular expressions against a character * sequence shall be performed without regard to case. */ - constexpr syntax_option_type icase = + _GLIBCXX17_INLINE constexpr syntax_option_type icase = static_cast(1 << _S_icase); /** @@ -92,7 +92,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * container sequence, no sub-expression matches are to be stored in the * supplied match_results structure. */ - constexpr syntax_option_type nosubs = + _GLIBCXX17_INLINE constexpr syntax_option_type nosubs = static_cast(1 << _S_nosubs); /** @@ -101,14 +101,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * speed with which regular expression objects are constructed. Otherwise * it has no detectable effect on the program output. */ - constexpr syntax_option_type optimize = + _GLIBCXX17_INLINE constexpr syntax_option_type optimize = static_cast(1 << _S_optimize); /** * Specifies that character ranges of the form [a-b] should be locale * sensitive. */ - constexpr syntax_option_type collate = + _GLIBCXX17_INLINE constexpr syntax_option_type collate = static_cast(1 << _S_collate); /** @@ -119,7 +119,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * in the PERL scripting language but extended with elements found in the * POSIX regular expression grammar. */ - constexpr syntax_option_type ECMAScript = + _GLIBCXX17_INLINE constexpr syntax_option_type ECMAScript = static_cast(1 << _S_ECMAScript); /** @@ -129,7 +129,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * Headers, Section 9, Regular Expressions [IEEE, Information Technology -- * Portable Operating System Interface (POSIX), IEEE Standard 1003.1-2001]. */ - constexpr syntax_option_type basic = + _GLIBCXX17_INLINE constexpr syntax_option_type basic = static_cast(1 << _S_basic); /** @@ -138,7 +138,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * Portable Operating System Interface (POSIX), Base Definitions and * Headers, Section 9, Regular Expressions. */ - constexpr syntax_option_type extended = + _GLIBCXX17_INLINE constexpr syntax_option_type extended = static_cast(1 << _S_extended); /** @@ -149,7 +149,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * \\\\, \\a, \\b, \\f, \\n, \\r, \\t , \\v, \\&apos,, &apos,, * and \\ddd (where ddd is one, two, or three octal digits). */ - constexpr syntax_option_type awk = + _GLIBCXX17_INLINE constexpr syntax_option_type awk = static_cast(1 << _S_awk); /** @@ -158,7 +158,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * identical to syntax_option_type basic, except that newlines are treated * as whitespace. */ - constexpr syntax_option_type grep = + _GLIBCXX17_INLINE constexpr syntax_option_type grep = static_cast(1 << _S_grep); /** @@ -167,7 +167,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * IEEE Std 1003.1-2001. This option is identical to syntax_option_type * extended, except that newlines are treated as whitespace. */ - constexpr syntax_option_type egrep = + _GLIBCXX17_INLINE constexpr syntax_option_type egrep = static_cast(1 << _S_egrep); /** @@ -176,7 +176,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * If specified in a regex with back-references, the exception * regex_constants::error_complexity will be thrown. */ - constexpr syntax_option_type __polynomial = + _GLIBCXX17_INLINE constexpr syntax_option_type __polynomial = static_cast(1 << _S_polynomial); constexpr inline syntax_option_type @@ -257,14 +257,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /** * The default matching rules. */ - constexpr match_flag_type match_default = static_cast(0); + _GLIBCXX17_INLINE constexpr match_flag_type match_default = + static_cast(0); /** * The first character in the sequence [first, last) is treated as though it * is not at the beginning of a line, so the character (^) in the regular * expression shall not match [first, first). */ - constexpr match_flag_type match_not_bol = + _GLIBCXX17_INLINE constexpr match_flag_type match_not_bol = static_cast(1 << _S_not_bol); /** @@ -272,40 +273,40 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * is not at the end of a line, so the character ($) in the regular * expression shall not match [last, last). */ - constexpr match_flag_type match_not_eol = + _GLIBCXX17_INLINE constexpr match_flag_type match_not_eol = static_cast(1 << _S_not_eol); /** * The expression \\b is not matched against the sub-sequence * [first,first). */ - constexpr match_flag_type match_not_bow = + _GLIBCXX17_INLINE constexpr match_flag_type match_not_bow = static_cast(1 << _S_not_bow); /** * The expression \\b should not be matched against the sub-sequence * [last,last). */ - constexpr match_flag_type match_not_eow = + _GLIBCXX17_INLINE constexpr match_flag_type match_not_eow = static_cast(1 << _S_not_eow); /** * If more than one match is possible then any match is an acceptable * result. */ - constexpr match_flag_type match_any = + _GLIBCXX17_INLINE constexpr match_flag_type match_any = static_cast(1 << _S_any); /** * The expression does not match an empty sequence. */ - constexpr match_flag_type match_not_null = + _GLIBCXX17_INLINE constexpr match_flag_type match_not_null = static_cast(1 << _S_not_null); /** * The expression only matches a sub-sequence that begins at first . */ - constexpr match_flag_type match_continuous = + _GLIBCXX17_INLINE constexpr match_flag_type match_continuous = static_cast(1 << _S_continuous); /** @@ -313,7 +314,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * flags match_not_bol and match_not_bow are ignored by the regular * expression algorithms 28.11 and iterators 28.12. */ - constexpr match_flag_type match_prev_avail = + _GLIBCXX17_INLINE constexpr match_flag_type match_prev_avail = static_cast(1 << _S_prev_avail); /** @@ -342,7 +343,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * undefined, use the empty string instead. If * nn > match_results::size(), the result is implementation-defined. */ - constexpr match_flag_type format_default = static_cast(0); + _GLIBCXX17_INLINE constexpr match_flag_type format_default = + static_cast(0); /** * When a regular expression match is to be replaced by a new string, the @@ -350,7 +352,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * in IEEE Std 1003.1- 2001 [IEEE, Information Technology -- Portable * Operating System Interface (POSIX), IEEE Standard 1003.1-2001]. */ - constexpr match_flag_type format_sed = + _GLIBCXX17_INLINE constexpr match_flag_type format_sed = static_cast(1 << _S_sed); /** @@ -358,14 +360,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * container sequence being searched that do not match the regular * expression shall not be copied to the output string. */ - constexpr match_flag_type format_no_copy = + _GLIBCXX17_INLINE constexpr match_flag_type format_no_copy = static_cast(1 << _S_no_copy); /** * When specified during a search and replace operation, only the first * occurrence of the regular expression shall be replaced. */ - constexpr match_flag_type format_first_only = + _GLIBCXX17_INLINE constexpr match_flag_type format_first_only = static_cast(1 << _S_first_only); constexpr inline match_flag_type diff --git a/libstdc++-v3/include/bits/std_mutex.h b/libstdc++-v3/include/bits/std_mutex.h index a434ee6bf5f..17d55f55764 100644 --- a/libstdc++-v3/include/bits/std_mutex.h +++ b/libstdc++-v3/include/bits/std_mutex.h @@ -139,13 +139,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct adopt_lock_t { explicit adopt_lock_t() = default; }; /// Tag used to prevent a scoped lock from acquiring ownership of a mutex. - constexpr defer_lock_t defer_lock { }; + _GLIBCXX17_INLINE constexpr defer_lock_t defer_lock { }; /// Tag used to prevent a scoped lock from blocking if a mutex is locked. - constexpr try_to_lock_t try_to_lock { }; + _GLIBCXX17_INLINE constexpr try_to_lock_t try_to_lock { }; /// Tag used to make a scoped lock take ownership of a locked mutex. - constexpr adopt_lock_t adopt_lock { }; + _GLIBCXX17_INLINE constexpr adopt_lock_t adopt_lock { }; /** @brief A simple scoped lock type. * diff --git a/libstdc++-v3/include/bits/stl_pair.h b/libstdc++-v3/include/bits/stl_pair.h index 66f52b3358e..7c7cee262a6 100644 --- a/libstdc++-v3/include/bits/stl_pair.h +++ b/libstdc++-v3/include/bits/stl_pair.h @@ -76,7 +76,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct piecewise_construct_t { explicit piecewise_construct_t() = default; }; /// piecewise_construct - constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t(); + _GLIBCXX17_INLINE constexpr piecewise_construct_t piecewise_construct = + piecewise_construct_t(); // Forward declarations. template diff --git a/libstdc++-v3/include/bits/uses_allocator.h b/libstdc++-v3/include/bits/uses_allocator.h index 8dd2adb8589..89d4e435659 100644 --- a/libstdc++-v3/include/bits/uses_allocator.h +++ b/libstdc++-v3/include/bits/uses_allocator.h @@ -45,7 +45,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// [allocator.tag] struct allocator_arg_t { explicit allocator_arg_t() = default; }; - constexpr allocator_arg_t allocator_arg = allocator_arg_t(); + _GLIBCXX17_INLINE constexpr allocator_arg_t allocator_arg = + allocator_arg_t(); template> struct __uses_allocator_helper @@ -110,7 +111,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } #if __cplusplus > 201402L template - constexpr bool uses_allocator_v = uses_allocator<_Tp, _Alloc>::value; + inline constexpr bool uses_allocator_v = + uses_allocator<_Tp, _Alloc>::value; #endif // C++17 template class _Predicate, @@ -128,7 +130,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus >= 201402L template - constexpr bool __is_uses_allocator_constructible_v = + _GLIBCXX17_INLINE constexpr bool __is_uses_allocator_constructible_v = __is_uses_allocator_constructible<_Tp, _Alloc, _Args...>::value; #endif // C++14 @@ -141,7 +143,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus >= 201402L template - constexpr bool __is_nothrow_uses_allocator_constructible_v = + _GLIBCXX17_INLINE constexpr bool + __is_nothrow_uses_allocator_constructible_v = __is_nothrow_uses_allocator_constructible<_Tp, _Alloc, _Args...>::value; #endif // C++14 diff --git a/libstdc++-v3/include/std/chrono b/libstdc++-v3/include/std/chrono index b3dc430b67a..c3a6ba8f873 100644 --- a/libstdc++-v3/include/std/chrono +++ b/libstdc++-v3/include/std/chrono @@ -211,7 +211,7 @@ _GLIBCXX_END_NAMESPACE_VERSION #if __cplusplus > 201402L template - constexpr bool treat_as_floating_point_v = + inline constexpr bool treat_as_floating_point_v = treat_as_floating_point<_Rep>::value; #endif // C++17 diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional index 3db10cade1c..06612537c43 100644 --- a/libstdc++-v3/include/std/functional +++ b/libstdc++-v3/include/std/functional @@ -242,9 +242,9 @@ _GLIBCXX_MEM_FN_TRAITS(&&, false_type, true_type) { }; #if __cplusplus > 201402L - template constexpr bool is_bind_expression_v + template inline constexpr bool is_bind_expression_v = is_bind_expression<_Tp>::value; - template constexpr int is_placeholder_v + template inline constexpr int is_placeholder_v = is_placeholder<_Tp>::value; #endif // C++17 diff --git a/libstdc++-v3/include/std/optional b/libstdc++-v3/include/std/optional index 3f540ec14b7..24802bf9e23 100644 --- a/libstdc++-v3/include/std/optional +++ b/libstdc++-v3/include/std/optional @@ -69,7 +69,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; /// Tag to disengage optional objects. - constexpr nullopt_t nullopt { nullopt_t::_Construct::_Token }; + inline constexpr nullopt_t nullopt { nullopt_t::_Construct::_Token }; /** * @brief Exception class thrown when a disengaged optional object is diff --git a/libstdc++-v3/include/std/ratio b/libstdc++-v3/include/std/ratio index 0d4d564ebaf..421f6a874b9 100644 --- a/libstdc++-v3/include/std/ratio +++ b/libstdc++-v3/include/std/ratio @@ -403,17 +403,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus > 201402L template - constexpr bool ratio_equal_v = ratio_equal<_R1, _R2>::value; + inline constexpr bool ratio_equal_v = ratio_equal<_R1, _R2>::value; template - constexpr bool ratio_not_equal_v = ratio_not_equal<_R1, _R2>::value; + inline constexpr bool ratio_not_equal_v = ratio_not_equal<_R1, _R2>::value; template - constexpr bool ratio_less_v = ratio_less<_R1, _R2>::value; + inline constexpr bool ratio_less_v = ratio_less<_R1, _R2>::value; template - constexpr bool ratio_less_equal_v = ratio_less_equal<_R1, _R2>::value; + inline constexpr bool ratio_less_equal_v = + ratio_less_equal<_R1, _R2>::value; template - constexpr bool ratio_greater_v = ratio_greater<_R1, _R2>::value; + inline constexpr bool ratio_greater_v = ratio_greater<_R1, _R2>::value; template - constexpr bool ratio_greater_equal_v + inline constexpr bool ratio_greater_equal_v = ratio_greater_equal<_R1, _R2>::value; #endif // C++17 diff --git a/libstdc++-v3/include/std/system_error b/libstdc++-v3/include/std/system_error index 7c2c1345d56..6775a6ea757 100644 --- a/libstdc++-v3/include/std/system_error +++ b/libstdc++-v3/include/std/system_error @@ -62,9 +62,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus > 201402L template - constexpr bool is_error_code_enum_v = is_error_code_enum<_Tp>::value; + inline constexpr bool is_error_code_enum_v = + is_error_code_enum<_Tp>::value; template - constexpr bool is_error_condition_enum_v = + inline constexpr bool is_error_condition_enum_v = is_error_condition_enum<_Tp>::value; #endif // C++17 inline namespace _V2 { diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple index ae495d9dc51..1f5365ad026 100644 --- a/libstdc++-v3/include/std/tuple +++ b/libstdc++-v3/include/std/tuple @@ -1268,7 +1268,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus > 201402L template - constexpr size_t tuple_size_v = tuple_size<_Tp>::value; + inline constexpr size_t tuple_size_v = tuple_size<_Tp>::value; #endif /** @@ -1610,16 +1610,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif // A class (and instance) which can be used in 'tie' when an element - // of a tuple is not required + // of a tuple is not required. + // _GLIBCXX14_CONSTEXPR + // 2933. PR for LWG 2773 could be clearer struct _Swallow_assign { template - const _Swallow_assign& + _GLIBCXX14_CONSTEXPR const _Swallow_assign& operator=(const _Tp&) const { return *this; } }; - const _Swallow_assign ignore{}; + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2773. Making std::ignore constexpr + _GLIBCXX17_INLINE constexpr _Swallow_assign ignore{}; /// Partial specialization for tuples template diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 7d067cabd72..6707caaefc5 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -174,15 +174,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { }; template - constexpr bool conjunction_v + inline constexpr bool conjunction_v = conjunction<_Bn...>::value; template - constexpr bool disjunction_v + inline constexpr bool disjunction_v = disjunction<_Bn...>::value; template - constexpr bool negation_v + inline constexpr bool negation_v = negation<_Pp>::value; #endif @@ -2656,11 +2656,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus >= 201402L /// is_swappable_v template - constexpr bool is_swappable_v = is_swappable<_Tp>::value; + _GLIBCXX17_INLINE constexpr bool is_swappable_v = + is_swappable<_Tp>::value; /// is_nothrow_swappable_v template - constexpr bool is_nothrow_swappable_v = is_nothrow_swappable<_Tp>::value; + _GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_v = + is_nothrow_swappable<_Tp>::value; #endif // __cplusplus >= 201402L namespace __swappable_with_details { @@ -2738,11 +2740,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus >= 201402L /// is_swappable_with_v template - constexpr bool is_swappable_with_v = is_swappable_with<_Tp, _Up>::value; + _GLIBCXX17_INLINE constexpr bool is_swappable_with_v = + is_swappable_with<_Tp, _Up>::value; /// is_nothrow_swappable_with_v template - constexpr bool is_nothrow_swappable_with_v = + _GLIBCXX17_INLINE constexpr bool is_nothrow_swappable_with_v = is_nothrow_swappable_with<_Tp, _Up>::value; #endif // __cplusplus >= 201402L @@ -2884,155 +2887,161 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus > 201402L # define __cpp_lib_type_trait_variable_templates 201510L template - constexpr bool is_void_v = is_void<_Tp>::value; + inline constexpr bool is_void_v = is_void<_Tp>::value; template - constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value; + inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value; template - constexpr bool is_integral_v = is_integral<_Tp>::value; + inline constexpr bool is_integral_v = is_integral<_Tp>::value; template - constexpr bool is_floating_point_v = is_floating_point<_Tp>::value; + inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value; template - constexpr bool is_array_v = is_array<_Tp>::value; + inline constexpr bool is_array_v = is_array<_Tp>::value; template - constexpr bool is_pointer_v = is_pointer<_Tp>::value; + inline constexpr bool is_pointer_v = is_pointer<_Tp>::value; template - constexpr bool is_lvalue_reference_v = is_lvalue_reference<_Tp>::value; + inline constexpr bool is_lvalue_reference_v = + is_lvalue_reference<_Tp>::value; template - constexpr bool is_rvalue_reference_v = is_rvalue_reference<_Tp>::value; + inline constexpr bool is_rvalue_reference_v = + is_rvalue_reference<_Tp>::value; template - constexpr bool is_member_object_pointer_v = + inline constexpr bool is_member_object_pointer_v = is_member_object_pointer<_Tp>::value; template - constexpr bool is_member_function_pointer_v = + inline constexpr bool is_member_function_pointer_v = is_member_function_pointer<_Tp>::value; template - constexpr bool is_enum_v = is_enum<_Tp>::value; + inline constexpr bool is_enum_v = is_enum<_Tp>::value; template - constexpr bool is_union_v = is_union<_Tp>::value; + inline constexpr bool is_union_v = is_union<_Tp>::value; template - constexpr bool is_class_v = is_class<_Tp>::value; + inline constexpr bool is_class_v = is_class<_Tp>::value; template - constexpr bool is_function_v = is_function<_Tp>::value; + inline constexpr bool is_function_v = is_function<_Tp>::value; template - constexpr bool is_reference_v = is_reference<_Tp>::value; + inline constexpr bool is_reference_v = is_reference<_Tp>::value; template - constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value; + inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value; template - constexpr bool is_fundamental_v = is_fundamental<_Tp>::value; + inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value; template - constexpr bool is_object_v = is_object<_Tp>::value; + inline constexpr bool is_object_v = is_object<_Tp>::value; template - constexpr bool is_scalar_v = is_scalar<_Tp>::value; + inline constexpr bool is_scalar_v = is_scalar<_Tp>::value; template - constexpr bool is_compound_v = is_compound<_Tp>::value; + inline constexpr bool is_compound_v = is_compound<_Tp>::value; template - constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value; + inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value; template - constexpr bool is_const_v = is_const<_Tp>::value; + inline constexpr bool is_const_v = is_const<_Tp>::value; template - constexpr bool is_volatile_v = is_volatile<_Tp>::value; + inline constexpr bool is_volatile_v = is_volatile<_Tp>::value; template - constexpr bool is_trivial_v = is_trivial<_Tp>::value; + inline constexpr bool is_trivial_v = is_trivial<_Tp>::value; template - constexpr bool is_trivially_copyable_v = is_trivially_copyable<_Tp>::value; + inline constexpr bool is_trivially_copyable_v = + is_trivially_copyable<_Tp>::value; template - constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value; + inline constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value; template - constexpr bool is_pod_v = is_pod<_Tp>::value; + inline constexpr bool is_pod_v = is_pod<_Tp>::value; template - constexpr bool is_literal_type_v = is_literal_type<_Tp>::value; + inline constexpr bool is_literal_type_v = is_literal_type<_Tp>::value; template - constexpr bool is_empty_v = is_empty<_Tp>::value; + inline constexpr bool is_empty_v = is_empty<_Tp>::value; template - constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value; + inline constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value; template - constexpr bool is_abstract_v = is_abstract<_Tp>::value; + inline constexpr bool is_abstract_v = is_abstract<_Tp>::value; template - constexpr bool is_final_v = is_final<_Tp>::value; + inline constexpr bool is_final_v = is_final<_Tp>::value; template - constexpr bool is_signed_v = is_signed<_Tp>::value; + inline constexpr bool is_signed_v = is_signed<_Tp>::value; template - constexpr bool is_unsigned_v = is_unsigned<_Tp>::value; + inline constexpr bool is_unsigned_v = is_unsigned<_Tp>::value; template - constexpr bool is_constructible_v = is_constructible<_Tp, _Args...>::value; + inline constexpr bool is_constructible_v = + is_constructible<_Tp, _Args...>::value; template - constexpr bool is_default_constructible_v = + inline constexpr bool is_default_constructible_v = is_default_constructible<_Tp>::value; template - constexpr bool is_copy_constructible_v = is_copy_constructible<_Tp>::value; + inline constexpr bool is_copy_constructible_v = + is_copy_constructible<_Tp>::value; template - constexpr bool is_move_constructible_v = is_move_constructible<_Tp>::value; + inline constexpr bool is_move_constructible_v = + is_move_constructible<_Tp>::value; template - constexpr bool is_assignable_v = is_assignable<_Tp, _Up>::value; + inline constexpr bool is_assignable_v = is_assignable<_Tp, _Up>::value; template - constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value; + inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value; template - constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value; + inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value; template - constexpr bool is_destructible_v = is_destructible<_Tp>::value; + inline constexpr bool is_destructible_v = is_destructible<_Tp>::value; template - constexpr bool is_trivially_constructible_v = + inline constexpr bool is_trivially_constructible_v = is_trivially_constructible<_Tp, _Args...>::value; template - constexpr bool is_trivially_default_constructible_v = + inline constexpr bool is_trivially_default_constructible_v = is_trivially_default_constructible<_Tp>::value; template - constexpr bool is_trivially_copy_constructible_v = + inline constexpr bool is_trivially_copy_constructible_v = is_trivially_copy_constructible<_Tp>::value; template - constexpr bool is_trivially_move_constructible_v = + inline constexpr bool is_trivially_move_constructible_v = is_trivially_move_constructible<_Tp>::value; template - constexpr bool is_trivially_assignable_v = + inline constexpr bool is_trivially_assignable_v = is_trivially_assignable<_Tp, _Up>::value; template - constexpr bool is_trivially_copy_assignable_v = + inline constexpr bool is_trivially_copy_assignable_v = is_trivially_copy_assignable<_Tp>::value; template - constexpr bool is_trivially_move_assignable_v = + inline constexpr bool is_trivially_move_assignable_v = is_trivially_move_assignable<_Tp>::value; template - constexpr bool is_trivially_destructible_v = + inline constexpr bool is_trivially_destructible_v = is_trivially_destructible<_Tp>::value; template - constexpr bool is_nothrow_constructible_v = + inline constexpr bool is_nothrow_constructible_v = is_nothrow_constructible<_Tp, _Args...>::value; template - constexpr bool is_nothrow_default_constructible_v = + inline constexpr bool is_nothrow_default_constructible_v = is_nothrow_default_constructible<_Tp>::value; template - constexpr bool is_nothrow_copy_constructible_v = + inline constexpr bool is_nothrow_copy_constructible_v = is_nothrow_copy_constructible<_Tp>::value; template - constexpr bool is_nothrow_move_constructible_v = + inline constexpr bool is_nothrow_move_constructible_v = is_nothrow_move_constructible<_Tp>::value; template - constexpr bool is_nothrow_assignable_v = + inline constexpr bool is_nothrow_assignable_v = is_nothrow_assignable<_Tp, _Up>::value; template - constexpr bool is_nothrow_copy_assignable_v = + inline constexpr bool is_nothrow_copy_assignable_v = is_nothrow_copy_assignable<_Tp>::value; template - constexpr bool is_nothrow_move_assignable_v = + inline constexpr bool is_nothrow_move_assignable_v = is_nothrow_move_assignable<_Tp>::value; template - constexpr bool is_nothrow_destructible_v = + inline constexpr bool is_nothrow_destructible_v = is_nothrow_destructible<_Tp>::value; template - constexpr bool has_virtual_destructor_v = + inline constexpr bool has_virtual_destructor_v = has_virtual_destructor<_Tp>::value; template - constexpr size_t alignment_of_v = alignment_of<_Tp>::value; + inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value; template - constexpr size_t rank_v = rank<_Tp>::value; + inline constexpr size_t rank_v = rank<_Tp>::value; template - constexpr size_t extent_v = extent<_Tp, _Idx>::value; + inline constexpr size_t extent_v = extent<_Tp, _Idx>::value; template - constexpr bool is_same_v = is_same<_Tp, _Up>::value; + inline constexpr bool is_same_v = is_same<_Tp, _Up>::value; template - constexpr bool is_base_of_v = is_base_of<_Base, _Derived>::value; + inline constexpr bool is_base_of_v = is_base_of<_Base, _Derived>::value; template - constexpr bool is_convertible_v = is_convertible<_From, _To>::value; + inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value; #ifdef __has_builtin # if !__has_builtin(__has_unique_object_representations) diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant index 58bf8c7b017..272b2a6f6d2 100644 --- a/libstdc++-v3/include/std/variant +++ b/libstdc++-v3/include/std/variant @@ -91,7 +91,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : std::integral_constant {}; template - constexpr size_t variant_size_v = variant_size<_Variant>::value; + inline constexpr size_t variant_size_v = variant_size<_Variant>::value; template struct variant_alternative; @@ -120,7 +120,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct variant_alternative<_Np, const volatile _Variant> { using type = add_cv_t>; }; - constexpr size_t variant_npos = -1; + inline constexpr size_t variant_npos = -1; template constexpr variant_alternative_t<_Np, variant<_Types...>>& @@ -151,7 +151,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __index_of : std::integral_constant {}; template - constexpr size_t __index_of_v = __index_of<_Tp, _Types...>::value; + inline constexpr size_t __index_of_v = __index_of<_Tp, _Types...>::value; template struct __index_of<_Tp, _First, _Rest...> : @@ -510,7 +510,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __tuple_count; template - constexpr size_t __tuple_count_v = __tuple_count<_Tp, _Tuple>::value; + inline constexpr size_t __tuple_count_v = + __tuple_count<_Tp, _Tuple>::value; template struct __tuple_count<_Tp, tuple<_Types...>> @@ -524,7 +525,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // TODO: Reuse this in ? template - constexpr bool __exactly_once = __tuple_count_v<_Tp, tuple<_Types...>> == 1; + inline constexpr bool __exactly_once = + __tuple_count_v<_Tp, tuple<_Types...>> == 1; // Takes _Types and create an overloaded _S_fun for each type. // If a type appears more than once in _Types, create only one overload. diff --git a/libstdc++-v3/testsuite/18_support/headers/new/synopsis.cc b/libstdc++-v3/testsuite/18_support/headers/new/synopsis.cc index 3f677b3c5bc..66ea3cc1782 100644 --- a/libstdc++-v3/testsuite/18_support/headers/new/synopsis.cc +++ b/libstdc++-v3/testsuite/18_support/headers/new/synopsis.cc @@ -30,8 +30,10 @@ namespace std { #if __cplusplus > 201402L enum class align_val_t : size_t; - // static constexpr size_t hardware_destructive_interference_size; - // static constexpr size_t hardware_constructive_interference_size; + // _GLIBCXX17_INLINE constexpr size_t + // hardware_destructive_interference_size; + // _GLIBCXX17_INLINE constexpr size_t + // hardware_constructive_interference_size; #endif } diff --git a/libstdc++-v3/testsuite/20_util/ratio/operations/ops_overflow_neg.cc b/libstdc++-v3/testsuite/20_util/ratio/operations/ops_overflow_neg.cc index a97d43eca99..e200a7a3ace 100644 --- a/libstdc++-v3/testsuite/20_util/ratio/operations/ops_overflow_neg.cc +++ b/libstdc++-v3/testsuite/20_util/ratio/operations/ops_overflow_neg.cc @@ -41,7 +41,7 @@ test02() // { dg-error "required from here" "" { target *-*-* } 28 } // { dg-error "expected initializer" "" { target *-*-* } 35 } // { dg-error "expected initializer" "" { target *-*-* } 37 } -// { dg-error "overflow in addition" "" { target *-*-* } 451 } +// { dg-error "overflow in addition" "" { target *-*-* } 452 } // { dg-error "overflow in multiplication" "" { target *-*-* } 97 } // { dg-error "overflow in multiplication" "" { target *-*-* } 99 } // { dg-error "overflow in multiplication" "" { target *-*-* } 101 } diff --git a/libstdc++-v3/testsuite/20_util/scoped_allocator/69293_neg.cc b/libstdc++-v3/testsuite/20_util/scoped_allocator/69293_neg.cc index f709336e2d6..9181d611b8a 100644 --- a/libstdc++-v3/testsuite/20_util/scoped_allocator/69293_neg.cc +++ b/libstdc++-v3/testsuite/20_util/scoped_allocator/69293_neg.cc @@ -46,5 +46,5 @@ test01() scoped_alloc sa; auto p = sa.allocate(1); sa.construct(p); // this is required to be ill-formed - // { dg-error "static assertion failed" "" { target *-*-* } 89 } + // { dg-error "static assertion failed" "" { target *-*-* } 90 } } diff --git a/libstdc++-v3/testsuite/20_util/tuple/creation_functions/constexpr.cc b/libstdc++-v3/testsuite/20_util/tuple/creation_functions/constexpr.cc index 6b04be806d3..ae3ca935a22 100644 --- a/libstdc++-v3/testsuite/20_util/tuple/creation_functions/constexpr.cc +++ b/libstdc++-v3/testsuite/20_util/tuple/creation_functions/constexpr.cc @@ -118,6 +118,25 @@ test_tuple_cat() constexpr auto cat1 __attribute__((unused)) = std::tuple_cat(t1, t2); } +namespace { + +template +constexpr int zero_from_anything(T) +{ + return 0; +} + +} + +// ignore, see LWG 2773 +void +test_ignore() +{ + constexpr auto ign1 __attribute__((unused)) = std::ignore; + constexpr auto ign2 __attribute__((unused)) = std::make_tuple(std::ignore); + constexpr int ign3 __attribute__((unused)) = zero_from_anything(std::ignore); +} + int main() { @@ -126,6 +145,7 @@ main() test_tie(); test_get(); test_tuple_cat(); + test_ignore(); return 0; } diff --git a/libstdc++-v3/testsuite/20_util/tuple/creation_functions/constexpr_cpp14.cc b/libstdc++-v3/testsuite/20_util/tuple/creation_functions/constexpr_cpp14.cc new file mode 100644 index 00000000000..18124ce67fc --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/creation_functions/constexpr_cpp14.cc @@ -0,0 +1,31 @@ +// { dg-do compile { target c++14 } } + +// Copyright (C) 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. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +// ignore, see LWG 2773 + LWG 2933. +constexpr bool +test_ignore() +{ + auto res = std::tie(std::ignore); + std::get<0>(res) = 42; + return true; +} + +static_assert(test_ignore(), "test_ignore failure"); diff --git a/libstdc++-v3/testsuite/20_util/uses_allocator/69293_neg.cc b/libstdc++-v3/testsuite/20_util/uses_allocator/69293_neg.cc index 3040b29ac3c..aa118ca2335 100644 --- a/libstdc++-v3/testsuite/20_util/uses_allocator/69293_neg.cc +++ b/libstdc++-v3/testsuite/20_util/uses_allocator/69293_neg.cc @@ -44,5 +44,5 @@ test01() { alloc_type a; std::tuple t(std::allocator_arg, a); // this is required to be ill-formed - // { dg-error "static assertion failed" "" { target *-*-* } 89 } + // { dg-error "static assertion failed" "" { target *-*-* } 90 } } diff --git a/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc b/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc index 2322e4b95c9..f7476365e3c 100644 --- a/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc +++ b/libstdc++-v3/testsuite/20_util/uses_allocator/cons_neg.cc @@ -43,4 +43,4 @@ void test01() tuple t(allocator_arg, a, 1); } -// { dg-error "static assertion failed" "" { target *-*-* } 89 } +// { dg-error "static assertion failed" "" { target *-*-* } 90 }