c++: satisfaction value of type const bool [PR104410]

Here constant evaluation of the atomic constraint use_func_v<T>
sensibly yields an INTEGER_CST of type const bool, but the assert in
satisfaction_value expects unqualified bool.  So let's just relax the
assert to accept cv-qualified bool.

	PR c++/104410

gcc/cp/ChangeLog:

	* constraint.cc (satisfaction_value): Relax assert to accept
	cv-qualified bool.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-pr104410.C: New test.
This commit is contained in:
Patrick Palka 2022-02-08 09:11:29 -05:00
parent db5f1c1703
commit 7ff201d85f
2 changed files with 8 additions and 1 deletions

View file

@ -2818,7 +2818,8 @@ satisfaction_value (tree t)
return t;
gcc_assert (TREE_CODE (t) == INTEGER_CST
&& same_type_p (TREE_TYPE (t), boolean_type_node));
&& same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (t),
boolean_type_node));
if (integer_zerop (t))
return boolean_false_node;
else

View file

@ -0,0 +1,6 @@
// PR c++/104410
// { dg-do compile { target c++20 } }
template<class T> constexpr bool use_func_v{};
template<class T> void f() requires use_func_v<T> || true { }
template void f<int>();