c++: constant direct-initialization [PR108243]
commit958940eb3511e341e57606f5a2f5399bc89533cb
authorJason Merrill <jason@redhat.com>
Wed, 13 Dec 2023 03:53:10 +0000 (12 22:53 -0500)
committerJason Merrill <jason@redhat.com>
Wed, 13 Dec 2023 16:25:19 +0000 (13 11:25 -0500)
treed831802c51130510adbc9d27d31787f7be55c02a
parent52b4b7d7f5c7c09f5aaf3934978de9702d8c214b
c++: constant direct-initialization [PR108243]

When testing the proposed patch for PR71093 I noticed that it changed the
diagnostic for consteval-prop6.C.  I then noticed that the diagnostic wasn't
very helpful either way; it was complaining about modification of the 'x'
variable, but it's not a problem to initialize a local variable with a
consteval constructor as long as the value is actually constant, we want to
know why the value isn't constant.  And then it turned out that this also
fixed a missed-optimization bug in the testsuite.

PR c++/108243

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_outermost_constant_expr): Turn
a constructor CALL_EXPR into a TARGET_EXPR.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/consteval-prop6.C: Adjust diagnostic.
* g++.dg/opt/is_constant_evaluated3.C: Remove xfails.
gcc/cp/constexpr.cc
gcc/testsuite/g++.dg/cpp2a/consteval-prop6.C
gcc/testsuite/g++.dg/opt/is_constant_evaluated3.C