gcc/libstdc++-v3/testsuite/26_numerics/random/concept.cc

256 lines
6.6 KiB
C++
Raw Permalink Normal View History

2025-01-02 11:59:57 +01:00
// Copyright (C) 2019-2025 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/>.
libstdc++: Remove dg-options "-std=gnu++20" from 26_numerics tests The testsuite will automatically select C++20 for these tests now, and removing the hardcoded -std option allows them to be tested for C++23 and C++26 as well. libstdc++-v3/ChangeLog: * testsuite/26_numerics/accumulate/constexpr.cc: Remove dg-options -std=gnu++2a. * testsuite/26_numerics/accumulate/lwg2055.cc: Likewise. * testsuite/26_numerics/adjacent_difference/constexpr.cc: Likewise. * testsuite/26_numerics/bit/bit.cast/105027.cc: Likewise. * testsuite/26_numerics/bit/bit.cast/bit_cast.cc: Likewise. * testsuite/26_numerics/bit/bit.cast/version.cc: Likewise. * testsuite/26_numerics/bit/bit.count/countl_one.cc: Likewise. * testsuite/26_numerics/bit/bit.pow.two/bit_ceil_neg.cc: Likewise. * testsuite/26_numerics/bit/bit.pow.two/bit_floor.cc: Likewise. * testsuite/26_numerics/bit/bit.pow.two/bit_width.cc: Likewise. * testsuite/26_numerics/bit/bit.pow.two/lwg3656.cc: Likewise. * testsuite/26_numerics/bit/bit.rotate/rotl.cc: Likewise. * testsuite/26_numerics/bit/bit.rotate/rotr.cc: Likewise. * testsuite/26_numerics/bit/header-2.cc: Likewise. * testsuite/26_numerics/bit/header.cc: Likewise. * testsuite/26_numerics/complex/1.cc: Likewise. * testsuite/26_numerics/complex/2.cc: Likewise. * testsuite/26_numerics/complex/comparison_operators/more_constexpr.cc: Likewise. * testsuite/26_numerics/complex/operators/more_constexpr.cc: Likewise. * testsuite/26_numerics/complex/requirements/more_constexpr.cc: Likewise. * testsuite/26_numerics/complex/value_operations/more_constexpr.cc: Likewise. * testsuite/26_numerics/endian/1.cc: Likewise. * testsuite/26_numerics/endian/2.cc: Likewise. * testsuite/26_numerics/endian/3.cc: Likewise. * testsuite/26_numerics/exclusive_scan/constexpr.cc: Likewise. * testsuite/26_numerics/inclusive_scan/constexpr.cc: Likewise. * testsuite/26_numerics/inner_product/constexpr.cc: Likewise. * testsuite/26_numerics/inner_product/lwg2055.cc: Likewise. * testsuite/26_numerics/iota/constexpr.cc: Likewise. * testsuite/26_numerics/lerp/1.cc: Likewise. * testsuite/26_numerics/lerp/constexpr.cc: Likewise. * testsuite/26_numerics/lerp/version.cc: Likewise. * testsuite/26_numerics/midpoint/floating.cc: Likewise. * testsuite/26_numerics/midpoint/integral.cc: Likewise. * testsuite/26_numerics/midpoint/pointer.cc: Likewise. * testsuite/26_numerics/midpoint/pointer_neg.cc: Likewise. * testsuite/26_numerics/midpoint/version.cc: Likewise. * testsuite/26_numerics/numbers/1.cc: Likewise. * testsuite/26_numerics/numbers/2.cc: Likewise. * testsuite/26_numerics/numbers/3.cc: Likewise. * testsuite/26_numerics/numbers/float128.cc: Likewise. * testsuite/26_numerics/numbers/nonfloat_neg.cc: Likewise. * testsuite/26_numerics/partial_sum/constexpr.cc: Likewise. * testsuite/26_numerics/partial_sum/lwg2055.cc: Likewise. * testsuite/26_numerics/random/concept.cc: Likewise. * testsuite/26_numerics/reduce/constexpr.cc: Likewise. * testsuite/26_numerics/slice/compare.cc: Likewise. * testsuite/26_numerics/transform_exclusive_scan/constexpr.cc: Likewise. * testsuite/26_numerics/transform_inclusive_scan/constexpr.cc: Likewise. * testsuite/26_numerics/transform_reduce/constexpr.cc: Likewise.
2023-09-15 14:27:56 +01:00
// { dg-do compile { target c++20 } }
// { dg-require-cstdint "" }
#include <random>
static_assert( std::uniform_random_bit_generator<std::default_random_engine> );
static_assert( std::uniform_random_bit_generator<std::minstd_rand0> );
static_assert( std::uniform_random_bit_generator<std::mt19937> );
struct G1
{
unsigned char operator()();
static constexpr unsigned char min() { return 0; }
static constexpr unsigned char max() { return 10; }
};
static_assert( std::uniform_random_bit_generator<G1> );
struct G2
{
unsigned operator()();
static constexpr unsigned min() { return 0; }
static constexpr unsigned max() { return -1U; }
};
static_assert( std::uniform_random_bit_generator<G2> );
struct G3
{
unsigned long long operator()();
static constexpr unsigned long long min() { return 0; }
static constexpr unsigned long long max() { return -1ULL; }
};
static_assert( std::uniform_random_bit_generator<G3> );
struct G4
{
unsigned operator()(int = 0, int = 0); // extra params, with default args
static constexpr unsigned min(long = 0) { return 0; }
static constexpr unsigned max(void* = nullptr) { return -1U; }
};
static_assert( std::uniform_random_bit_generator<G4> );
struct G5
{
unsigned operator()() &; // ref-qualifier
static constexpr unsigned min() { return 0; }
static constexpr unsigned max() { return 10; }
};
static_assert( std::uniform_random_bit_generator<G5> );
struct G6
{
unsigned operator()() const; // cv-qualifier
static constexpr unsigned min() { return 0; }
static constexpr unsigned max() { return 10; }
};
static_assert( std::uniform_random_bit_generator<G6> );
struct G7
{
unsigned operator()() volatile; // cv-qualifier
static constexpr unsigned min() { return 0; }
static constexpr unsigned max() { return 10; }
};
static_assert( std::uniform_random_bit_generator<G7> );
struct G8
{
unsigned operator()() const volatile; // cv-qualifiers
static constexpr unsigned min() { return 0; }
static constexpr unsigned max() { return 10; }
};
static_assert( std::uniform_random_bit_generator<G8> );
struct G9
{
unsigned operator()() const volatile; // cv-qualifiers
static constexpr unsigned min() { return 0; }
static constexpr unsigned max() { return 10; }
};
static_assert( std::uniform_random_bit_generator<G9> );
struct G10
{
unsigned operator()() const volatile & noexcept; // cv/ref/noexcept
static constexpr unsigned min() noexcept { return 0; }
static constexpr unsigned max() noexcept { return 10; }
};
static_assert( std::uniform_random_bit_generator<G10> );
// Negative tests.
static_assert( ! std::uniform_random_bit_generator<void> );
static_assert( ! std::uniform_random_bit_generator<int> );
static_assert( ! std::uniform_random_bit_generator<unsigned(*)()> );
struct N1
{
unsigned operator()();
constexpr unsigned min() { return 0; } // non-static
static constexpr unsigned max() { return 1; }
};
static_assert( ! std::uniform_random_bit_generator<N1> );
struct N2
{
unsigned operator()();
static constexpr unsigned min() { return 0; }
constexpr unsigned max() { return 1; } // non-static
};
static_assert( ! std::uniform_random_bit_generator<N2> );
struct N3
{
unsigned operator()();
// no N3::min()
static constexpr unsigned max() { return 1; }
};
static_assert( ! std::uniform_random_bit_generator<N3> );
struct N4
{
unsigned operator()();
static constexpr unsigned min() { return 0; }
// no N4::max()
};
static_assert( ! std::uniform_random_bit_generator<N4> );
struct N5
{
// no operator()
static constexpr unsigned min() { return 0; }
static constexpr unsigned max() { return 1; }
};
static_assert( ! std::uniform_random_bit_generator<N5> );
struct N6
{
int operator()(); // returns signed integral
static constexpr unsigned min() { return 0; }
static constexpr unsigned max() { return 1; }
};
static_assert( ! std::uniform_random_bit_generator<N6> );
struct N7
{
unsigned operator()();
static constexpr unsigned long min() { return 0; } // different return type
static constexpr unsigned max() { return 1; }
};
static_assert( ! std::uniform_random_bit_generator<N7> );
struct N8
{
unsigned operator()();
static constexpr unsigned min() { return 0; }
static constexpr unsigned long max() { return 1; } // different return type
};
static_assert( ! std::uniform_random_bit_generator<N8> );
struct N9
{
unsigned operator()();
static constexpr unsigned long min() { return 0; } // different return type
static constexpr unsigned long max() { return 1; } // different return type
};
static_assert( ! std::uniform_random_bit_generator<N9> );
struct N10
{
unsigned operator()() &&; // ref-qualifier
static constexpr unsigned min() { return 0; }
static constexpr unsigned max() { return 1; }
};
static_assert( ! std::uniform_random_bit_generator<N10> );
struct N11
{
unsigned operator()() const &&; // ref-qualifier
static constexpr unsigned min() { return 0; }
static constexpr unsigned max() { return 1; }
};
static_assert( ! std::uniform_random_bit_generator<N11> );
struct N12
{
unsigned operator()();
static unsigned min() { return 0; } // not constexpr
static constexpr unsigned max() { return 1; }
};
c++: Add -fimplicit-constexpr With each successive C++ standard the restrictions on the use of the constexpr keyword for functions get weaker and weaker; it recently occurred to me that it is heading toward the same fate as the C register keyword, which was once useful for optimization but became obsolete. Similarly, it seems to me that we should be able to just treat inlines as constexpr functions and not make people add the extra keyword everywhere. There were a lot of testcase changes needed; many disabling errors about non-constexpr functions that are now constexpr, and many disabling implicit constexpr so that the tests can check the same thing as before, whether that's mangling or whatever. gcc/c-family/ChangeLog: * c.opt: Add -fimplicit-constexpr. * c-cppbuiltin.c: Define __cpp_implicit_constexpr. * c-opts.c (c_common_post_options): Disable below C++14. gcc/cp/ChangeLog: * cp-tree.h (struct lang_decl_fn): Add implicit_constexpr. (decl_implicit_constexpr_p): New. * class.c (type_maybe_constexpr_destructor): Use TYPE_HAS_TRIVIAL_DESTRUCTOR and maybe_constexpr_fn. (finalize_literal_type_property): Simplify. * constexpr.c (is_valid_constexpr_fn): Check for dtor. (maybe_save_constexpr_fundef): Try to set DECL_DECLARED_CONSTEXPR_P on inlines. (cxx_eval_call_expression): Use maybe_constexpr_fn. (maybe_constexpr_fn): Handle flag_implicit_constexpr. (var_in_maybe_constexpr_fn): Use maybe_constexpr_fn. (potential_constant_expression_1): Likewise. (decl_implicit_constexpr_p): New. * decl.c (validate_constexpr_redeclaration): Allow change with -fimplicit-constexpr. (grok_special_member_properties): Use maybe_constexpr_fn. * error.c (dump_function_decl): Don't print 'constexpr' if it's implicit. * Make-lang.in (check-c++-all): Update. libstdc++-v3/ChangeLog: * testsuite/20_util/to_address/1_neg.cc: Adjust error. * testsuite/26_numerics/random/concept.cc: Adjust asserts. gcc/testsuite/ChangeLog: * lib/g++-dg.exp: Handle "impcx". * lib/target-supports.exp (check_effective_target_implicit_constexpr): New. * g++.dg/abi/abi-tag16.C: * g++.dg/abi/abi-tag18a.C: * g++.dg/abi/guard4.C: * g++.dg/abi/lambda-defarg1.C: * g++.dg/abi/mangle26.C: * g++.dg/cpp0x/constexpr-diag3.C: * g++.dg/cpp0x/constexpr-ex1.C: * g++.dg/cpp0x/constexpr-ice5.C: * g++.dg/cpp0x/constexpr-incomplete2.C: * g++.dg/cpp0x/constexpr-memfn1.C: * g++.dg/cpp0x/constexpr-neg3.C: * g++.dg/cpp0x/constexpr-specialization.C: * g++.dg/cpp0x/inh-ctor19.C: * g++.dg/cpp0x/inh-ctor30.C: * g++.dg/cpp0x/lambda/lambda-mangle3.C: * g++.dg/cpp0x/lambda/lambda-mangle5.C: * g++.dg/cpp1y/auto-fn12.C: * g++.dg/cpp1y/constexpr-loop5.C: * g++.dg/cpp1z/constexpr-lambda7.C: * g++.dg/cpp2a/constexpr-dtor3.C: * g++.dg/cpp2a/constexpr-new13.C: * g++.dg/cpp2a/constinit11.C: * g++.dg/cpp2a/constinit12.C: * g++.dg/cpp2a/constinit14.C: * g++.dg/cpp2a/constinit15.C: * g++.dg/cpp2a/spaceship-constexpr1.C: * g++.dg/cpp2a/spaceship-eq3.C: * g++.dg/cpp2a/udlit-class-nttp-neg2.C: * g++.dg/debug/dwarf2/auto1.C: * g++.dg/debug/dwarf2/cdtor-1.C: * g++.dg/debug/dwarf2/lambda1.C: * g++.dg/debug/dwarf2/pr54508.C: * g++.dg/debug/dwarf2/pubnames-2.C: * g++.dg/debug/dwarf2/pubnames-3.C: * g++.dg/ext/is_literal_type3.C: * g++.dg/ext/visibility/template7.C: * g++.dg/gcov/gcov-12.C: * g++.dg/gcov/gcov-2.C: * g++.dg/ipa/devirt-35.C: * g++.dg/ipa/devirt-36.C: * g++.dg/ipa/devirt-37.C: * g++.dg/ipa/devirt-44.C: * g++.dg/ipa/imm-devirt-1.C: * g++.dg/lookup/builtin5.C: * g++.dg/lto/inline-crossmodule-1_0.C: * g++.dg/modules/enum-1_a.C: * g++.dg/modules/fn-inline-1_c.C: * g++.dg/modules/pmf-1_b.C: * g++.dg/modules/used-1_c.C: * g++.dg/tls/thread_local11.C: * g++.dg/tls/thread_local11a.C: * g++.dg/tm/pr46653.C: * g++.dg/ubsan/pr70035.C: * g++.old-deja/g++.other/delete6.C: * g++.dg/modules/pmf-1_a.H: Adjust for implicit constexpr.
2021-10-13 11:47:25 -04:00
#if __cpp_implicit_constexpr
static_assert( std::uniform_random_bit_generator<N12> ); // LWG 3150
#else
static_assert( ! std::uniform_random_bit_generator<N12> ); // LWG 3150
c++: Add -fimplicit-constexpr With each successive C++ standard the restrictions on the use of the constexpr keyword for functions get weaker and weaker; it recently occurred to me that it is heading toward the same fate as the C register keyword, which was once useful for optimization but became obsolete. Similarly, it seems to me that we should be able to just treat inlines as constexpr functions and not make people add the extra keyword everywhere. There were a lot of testcase changes needed; many disabling errors about non-constexpr functions that are now constexpr, and many disabling implicit constexpr so that the tests can check the same thing as before, whether that's mangling or whatever. gcc/c-family/ChangeLog: * c.opt: Add -fimplicit-constexpr. * c-cppbuiltin.c: Define __cpp_implicit_constexpr. * c-opts.c (c_common_post_options): Disable below C++14. gcc/cp/ChangeLog: * cp-tree.h (struct lang_decl_fn): Add implicit_constexpr. (decl_implicit_constexpr_p): New. * class.c (type_maybe_constexpr_destructor): Use TYPE_HAS_TRIVIAL_DESTRUCTOR and maybe_constexpr_fn. (finalize_literal_type_property): Simplify. * constexpr.c (is_valid_constexpr_fn): Check for dtor. (maybe_save_constexpr_fundef): Try to set DECL_DECLARED_CONSTEXPR_P on inlines. (cxx_eval_call_expression): Use maybe_constexpr_fn. (maybe_constexpr_fn): Handle flag_implicit_constexpr. (var_in_maybe_constexpr_fn): Use maybe_constexpr_fn. (potential_constant_expression_1): Likewise. (decl_implicit_constexpr_p): New. * decl.c (validate_constexpr_redeclaration): Allow change with -fimplicit-constexpr. (grok_special_member_properties): Use maybe_constexpr_fn. * error.c (dump_function_decl): Don't print 'constexpr' if it's implicit. * Make-lang.in (check-c++-all): Update. libstdc++-v3/ChangeLog: * testsuite/20_util/to_address/1_neg.cc: Adjust error. * testsuite/26_numerics/random/concept.cc: Adjust asserts. gcc/testsuite/ChangeLog: * lib/g++-dg.exp: Handle "impcx". * lib/target-supports.exp (check_effective_target_implicit_constexpr): New. * g++.dg/abi/abi-tag16.C: * g++.dg/abi/abi-tag18a.C: * g++.dg/abi/guard4.C: * g++.dg/abi/lambda-defarg1.C: * g++.dg/abi/mangle26.C: * g++.dg/cpp0x/constexpr-diag3.C: * g++.dg/cpp0x/constexpr-ex1.C: * g++.dg/cpp0x/constexpr-ice5.C: * g++.dg/cpp0x/constexpr-incomplete2.C: * g++.dg/cpp0x/constexpr-memfn1.C: * g++.dg/cpp0x/constexpr-neg3.C: * g++.dg/cpp0x/constexpr-specialization.C: * g++.dg/cpp0x/inh-ctor19.C: * g++.dg/cpp0x/inh-ctor30.C: * g++.dg/cpp0x/lambda/lambda-mangle3.C: * g++.dg/cpp0x/lambda/lambda-mangle5.C: * g++.dg/cpp1y/auto-fn12.C: * g++.dg/cpp1y/constexpr-loop5.C: * g++.dg/cpp1z/constexpr-lambda7.C: * g++.dg/cpp2a/constexpr-dtor3.C: * g++.dg/cpp2a/constexpr-new13.C: * g++.dg/cpp2a/constinit11.C: * g++.dg/cpp2a/constinit12.C: * g++.dg/cpp2a/constinit14.C: * g++.dg/cpp2a/constinit15.C: * g++.dg/cpp2a/spaceship-constexpr1.C: * g++.dg/cpp2a/spaceship-eq3.C: * g++.dg/cpp2a/udlit-class-nttp-neg2.C: * g++.dg/debug/dwarf2/auto1.C: * g++.dg/debug/dwarf2/cdtor-1.C: * g++.dg/debug/dwarf2/lambda1.C: * g++.dg/debug/dwarf2/pr54508.C: * g++.dg/debug/dwarf2/pubnames-2.C: * g++.dg/debug/dwarf2/pubnames-3.C: * g++.dg/ext/is_literal_type3.C: * g++.dg/ext/visibility/template7.C: * g++.dg/gcov/gcov-12.C: * g++.dg/gcov/gcov-2.C: * g++.dg/ipa/devirt-35.C: * g++.dg/ipa/devirt-36.C: * g++.dg/ipa/devirt-37.C: * g++.dg/ipa/devirt-44.C: * g++.dg/ipa/imm-devirt-1.C: * g++.dg/lookup/builtin5.C: * g++.dg/lto/inline-crossmodule-1_0.C: * g++.dg/modules/enum-1_a.C: * g++.dg/modules/fn-inline-1_c.C: * g++.dg/modules/pmf-1_b.C: * g++.dg/modules/used-1_c.C: * g++.dg/tls/thread_local11.C: * g++.dg/tls/thread_local11a.C: * g++.dg/tm/pr46653.C: * g++.dg/ubsan/pr70035.C: * g++.old-deja/g++.other/delete6.C: * g++.dg/modules/pmf-1_a.H: Adjust for implicit constexpr.
2021-10-13 11:47:25 -04:00
#endif
struct N13
{
unsigned operator()();
static constexpr unsigned min() { return 0; }
static unsigned max() { return 1; } // not constexpr
};
c++: Add -fimplicit-constexpr With each successive C++ standard the restrictions on the use of the constexpr keyword for functions get weaker and weaker; it recently occurred to me that it is heading toward the same fate as the C register keyword, which was once useful for optimization but became obsolete. Similarly, it seems to me that we should be able to just treat inlines as constexpr functions and not make people add the extra keyword everywhere. There were a lot of testcase changes needed; many disabling errors about non-constexpr functions that are now constexpr, and many disabling implicit constexpr so that the tests can check the same thing as before, whether that's mangling or whatever. gcc/c-family/ChangeLog: * c.opt: Add -fimplicit-constexpr. * c-cppbuiltin.c: Define __cpp_implicit_constexpr. * c-opts.c (c_common_post_options): Disable below C++14. gcc/cp/ChangeLog: * cp-tree.h (struct lang_decl_fn): Add implicit_constexpr. (decl_implicit_constexpr_p): New. * class.c (type_maybe_constexpr_destructor): Use TYPE_HAS_TRIVIAL_DESTRUCTOR and maybe_constexpr_fn. (finalize_literal_type_property): Simplify. * constexpr.c (is_valid_constexpr_fn): Check for dtor. (maybe_save_constexpr_fundef): Try to set DECL_DECLARED_CONSTEXPR_P on inlines. (cxx_eval_call_expression): Use maybe_constexpr_fn. (maybe_constexpr_fn): Handle flag_implicit_constexpr. (var_in_maybe_constexpr_fn): Use maybe_constexpr_fn. (potential_constant_expression_1): Likewise. (decl_implicit_constexpr_p): New. * decl.c (validate_constexpr_redeclaration): Allow change with -fimplicit-constexpr. (grok_special_member_properties): Use maybe_constexpr_fn. * error.c (dump_function_decl): Don't print 'constexpr' if it's implicit. * Make-lang.in (check-c++-all): Update. libstdc++-v3/ChangeLog: * testsuite/20_util/to_address/1_neg.cc: Adjust error. * testsuite/26_numerics/random/concept.cc: Adjust asserts. gcc/testsuite/ChangeLog: * lib/g++-dg.exp: Handle "impcx". * lib/target-supports.exp (check_effective_target_implicit_constexpr): New. * g++.dg/abi/abi-tag16.C: * g++.dg/abi/abi-tag18a.C: * g++.dg/abi/guard4.C: * g++.dg/abi/lambda-defarg1.C: * g++.dg/abi/mangle26.C: * g++.dg/cpp0x/constexpr-diag3.C: * g++.dg/cpp0x/constexpr-ex1.C: * g++.dg/cpp0x/constexpr-ice5.C: * g++.dg/cpp0x/constexpr-incomplete2.C: * g++.dg/cpp0x/constexpr-memfn1.C: * g++.dg/cpp0x/constexpr-neg3.C: * g++.dg/cpp0x/constexpr-specialization.C: * g++.dg/cpp0x/inh-ctor19.C: * g++.dg/cpp0x/inh-ctor30.C: * g++.dg/cpp0x/lambda/lambda-mangle3.C: * g++.dg/cpp0x/lambda/lambda-mangle5.C: * g++.dg/cpp1y/auto-fn12.C: * g++.dg/cpp1y/constexpr-loop5.C: * g++.dg/cpp1z/constexpr-lambda7.C: * g++.dg/cpp2a/constexpr-dtor3.C: * g++.dg/cpp2a/constexpr-new13.C: * g++.dg/cpp2a/constinit11.C: * g++.dg/cpp2a/constinit12.C: * g++.dg/cpp2a/constinit14.C: * g++.dg/cpp2a/constinit15.C: * g++.dg/cpp2a/spaceship-constexpr1.C: * g++.dg/cpp2a/spaceship-eq3.C: * g++.dg/cpp2a/udlit-class-nttp-neg2.C: * g++.dg/debug/dwarf2/auto1.C: * g++.dg/debug/dwarf2/cdtor-1.C: * g++.dg/debug/dwarf2/lambda1.C: * g++.dg/debug/dwarf2/pr54508.C: * g++.dg/debug/dwarf2/pubnames-2.C: * g++.dg/debug/dwarf2/pubnames-3.C: * g++.dg/ext/is_literal_type3.C: * g++.dg/ext/visibility/template7.C: * g++.dg/gcov/gcov-12.C: * g++.dg/gcov/gcov-2.C: * g++.dg/ipa/devirt-35.C: * g++.dg/ipa/devirt-36.C: * g++.dg/ipa/devirt-37.C: * g++.dg/ipa/devirt-44.C: * g++.dg/ipa/imm-devirt-1.C: * g++.dg/lookup/builtin5.C: * g++.dg/lto/inline-crossmodule-1_0.C: * g++.dg/modules/enum-1_a.C: * g++.dg/modules/fn-inline-1_c.C: * g++.dg/modules/pmf-1_b.C: * g++.dg/modules/used-1_c.C: * g++.dg/tls/thread_local11.C: * g++.dg/tls/thread_local11a.C: * g++.dg/tm/pr46653.C: * g++.dg/ubsan/pr70035.C: * g++.old-deja/g++.other/delete6.C: * g++.dg/modules/pmf-1_a.H: Adjust for implicit constexpr.
2021-10-13 11:47:25 -04:00
#if __cpp_implicit_constexpr
static_assert( std::uniform_random_bit_generator<N13> ); // LWG 3150
#else
static_assert( ! std::uniform_random_bit_generator<N13> ); // LWG 3150
c++: Add -fimplicit-constexpr With each successive C++ standard the restrictions on the use of the constexpr keyword for functions get weaker and weaker; it recently occurred to me that it is heading toward the same fate as the C register keyword, which was once useful for optimization but became obsolete. Similarly, it seems to me that we should be able to just treat inlines as constexpr functions and not make people add the extra keyword everywhere. There were a lot of testcase changes needed; many disabling errors about non-constexpr functions that are now constexpr, and many disabling implicit constexpr so that the tests can check the same thing as before, whether that's mangling or whatever. gcc/c-family/ChangeLog: * c.opt: Add -fimplicit-constexpr. * c-cppbuiltin.c: Define __cpp_implicit_constexpr. * c-opts.c (c_common_post_options): Disable below C++14. gcc/cp/ChangeLog: * cp-tree.h (struct lang_decl_fn): Add implicit_constexpr. (decl_implicit_constexpr_p): New. * class.c (type_maybe_constexpr_destructor): Use TYPE_HAS_TRIVIAL_DESTRUCTOR and maybe_constexpr_fn. (finalize_literal_type_property): Simplify. * constexpr.c (is_valid_constexpr_fn): Check for dtor. (maybe_save_constexpr_fundef): Try to set DECL_DECLARED_CONSTEXPR_P on inlines. (cxx_eval_call_expression): Use maybe_constexpr_fn. (maybe_constexpr_fn): Handle flag_implicit_constexpr. (var_in_maybe_constexpr_fn): Use maybe_constexpr_fn. (potential_constant_expression_1): Likewise. (decl_implicit_constexpr_p): New. * decl.c (validate_constexpr_redeclaration): Allow change with -fimplicit-constexpr. (grok_special_member_properties): Use maybe_constexpr_fn. * error.c (dump_function_decl): Don't print 'constexpr' if it's implicit. * Make-lang.in (check-c++-all): Update. libstdc++-v3/ChangeLog: * testsuite/20_util/to_address/1_neg.cc: Adjust error. * testsuite/26_numerics/random/concept.cc: Adjust asserts. gcc/testsuite/ChangeLog: * lib/g++-dg.exp: Handle "impcx". * lib/target-supports.exp (check_effective_target_implicit_constexpr): New. * g++.dg/abi/abi-tag16.C: * g++.dg/abi/abi-tag18a.C: * g++.dg/abi/guard4.C: * g++.dg/abi/lambda-defarg1.C: * g++.dg/abi/mangle26.C: * g++.dg/cpp0x/constexpr-diag3.C: * g++.dg/cpp0x/constexpr-ex1.C: * g++.dg/cpp0x/constexpr-ice5.C: * g++.dg/cpp0x/constexpr-incomplete2.C: * g++.dg/cpp0x/constexpr-memfn1.C: * g++.dg/cpp0x/constexpr-neg3.C: * g++.dg/cpp0x/constexpr-specialization.C: * g++.dg/cpp0x/inh-ctor19.C: * g++.dg/cpp0x/inh-ctor30.C: * g++.dg/cpp0x/lambda/lambda-mangle3.C: * g++.dg/cpp0x/lambda/lambda-mangle5.C: * g++.dg/cpp1y/auto-fn12.C: * g++.dg/cpp1y/constexpr-loop5.C: * g++.dg/cpp1z/constexpr-lambda7.C: * g++.dg/cpp2a/constexpr-dtor3.C: * g++.dg/cpp2a/constexpr-new13.C: * g++.dg/cpp2a/constinit11.C: * g++.dg/cpp2a/constinit12.C: * g++.dg/cpp2a/constinit14.C: * g++.dg/cpp2a/constinit15.C: * g++.dg/cpp2a/spaceship-constexpr1.C: * g++.dg/cpp2a/spaceship-eq3.C: * g++.dg/cpp2a/udlit-class-nttp-neg2.C: * g++.dg/debug/dwarf2/auto1.C: * g++.dg/debug/dwarf2/cdtor-1.C: * g++.dg/debug/dwarf2/lambda1.C: * g++.dg/debug/dwarf2/pr54508.C: * g++.dg/debug/dwarf2/pubnames-2.C: * g++.dg/debug/dwarf2/pubnames-3.C: * g++.dg/ext/is_literal_type3.C: * g++.dg/ext/visibility/template7.C: * g++.dg/gcov/gcov-12.C: * g++.dg/gcov/gcov-2.C: * g++.dg/ipa/devirt-35.C: * g++.dg/ipa/devirt-36.C: * g++.dg/ipa/devirt-37.C: * g++.dg/ipa/devirt-44.C: * g++.dg/ipa/imm-devirt-1.C: * g++.dg/lookup/builtin5.C: * g++.dg/lto/inline-crossmodule-1_0.C: * g++.dg/modules/enum-1_a.C: * g++.dg/modules/fn-inline-1_c.C: * g++.dg/modules/pmf-1_b.C: * g++.dg/modules/used-1_c.C: * g++.dg/tls/thread_local11.C: * g++.dg/tls/thread_local11a.C: * g++.dg/tm/pr46653.C: * g++.dg/ubsan/pr70035.C: * g++.old-deja/g++.other/delete6.C: * g++.dg/modules/pmf-1_a.H: Adjust for implicit constexpr.
2021-10-13 11:47:25 -04:00
#endif
struct N14
{
unsigned operator()();
static constexpr unsigned min() { return 1; }
static constexpr unsigned max() { return 0; } // max not greater than min
};
static_assert( ! std::uniform_random_bit_generator<N14> ); // LWG 3150