diff options
-rw-r--r-- | gcc/cp/constraint.cc | 3 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp2a/concepts-requires31.C | 15 |
2 files changed, 18 insertions, 0 deletions
diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc index 5e6a3bc..f6ef078 100644 --- a/gcc/cp/constraint.cc +++ b/gcc/cp/constraint.cc @@ -2252,6 +2252,9 @@ tsubst_requires_expr (tree t, tree args, sat_info info) { local_specialization_stack stack (lss_copy); + /* We need to check access during the substitution. */ + deferring_access_check_sentinel acs (dk_no_deferred); + /* A requires-expression is an unevaluated context. */ cp_unevaluated u; diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-requires31.C b/gcc/testsuite/g++.dg/cpp2a/concepts-requires31.C new file mode 100644 index 0000000..cd26b9c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-requires31.C @@ -0,0 +1,15 @@ +// PR c++/107179 +// { dg-do compile { target c++20 } } + +template<bool B> struct bool_constant { static constexpr bool value = B; }; + +template<typename T> + struct is_implicitly_default_constructible + : bool_constant<requires { T(); }> + { }; + +struct X { private: X(); }; +struct Y { }; + +static_assert( !is_implicitly_default_constructible<X>::value ); +static_assert( is_implicitly_default_constructible<Y>::value ); |