c++: constexpr and -fno-elide-constructors [PR101072]
authorJason Merrill <jason@redhat.com>
Thu, 20 Jan 2022 10:45:02 +0000 (05:45 -0500)
committerJason Merrill <jason@redhat.com>
Sun, 23 Jan 2022 03:18:02 +0000 (22:18 -0500)
commit053bcc97f4a59e3f2811b8a1edf60fd733a580a0
tree67c0720cf64acec9f7a48c8e0f16b3e9936dc2b5
parentd43be9dcc1bef95d70fb411d98b4de0d83c6b85d
c++: constexpr and -fno-elide-constructors [PR101072]

We've been trying for a while to avoid TARGET_EXPRs in template code, but
there were still a few that snuck through, and the one in this case broke
the code that tried to handle it.  Fixed by using IMPLICIT_CONV_EXPR, as we
have done elsewhere.

I also noticed that finish_compound_literal was assuming that all T{init}
were for aggregate T, and we got a few more TARGET_EXPRs from that.  Fixed
by only messing with TARGET_EXPR if we actually have an aggregate init.

PR c++/101072

gcc/cp/ChangeLog:

* cp-tree.h (build_implicit_conv_flags): Declare.
* call.cc (build_implicit_conv_flags): Split out from...
(perform_implicit_conversion_flags): ...here.
* decl.cc (check_initializer): Use it.
* pt.cc (tsubst_copy_and_build): Remove TARGET_EXPR handling.
* semantics.cc (finish_compound_literal): Don't treat
scalar values like CONSTRUCTORs.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/constexpr-empty14a.C: New test.
gcc/cp/call.cc
gcc/cp/cp-tree.h
gcc/cp/decl.cc
gcc/cp/pt.cc
gcc/cp/semantics.cc
gcc/testsuite/g++.dg/cpp0x/constexpr-empty14a.C [new file with mode: 0644]