c++: improve failed constexpr assume diagnostic
commitac8f92c18886057261d61d45b8d339629464c77e
authorJason Merrill <jason@redhat.com>
Mon, 24 Oct 2022 21:17:24 +0000 (24 17:17 -0400)
committerJason Merrill <jason@redhat.com>
Tue, 25 Oct 2022 16:38:25 +0000 (25 12:38 -0400)
tree0e7beb4f9c726f91550e35f0bf96d2015bf8be79
parent4ba3902e8f1ee3ca35e3194053ebdc1e174808ea
c++: improve failed constexpr assume diagnostic

I noticed that we were printing "the comparison reduces to (x == 42)" when
we should be able to give the value of x.  Fixed by doing the same
evaluation in diagnose_failing_condition that we already do in
find_failing_clause.

gcc/cp/ChangeLog:

* constexpr.cc (fold_operand): New function.
(find_failing_clause_r): Add const.
(find_failing_clause): Add const.
(diagnose_failing_condition): Add ctx parameter.
(cxx_eval_internal_function): Pass it.
* semantics.cc (diagnose_failing_condition): Move to constexpr.cc.
* cp-tree.h: Adjust.

gcc/testsuite/ChangeLog:

* g++.dg/cpp23/attr-assume2.C: Expect constant values.
gcc/cp/constexpr.cc
gcc/cp/cp-tree.h
gcc/cp/semantics.cc
gcc/testsuite/g++.dg/cpp23/attr-assume2.C