]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Fix ICE due to folding a call to constructor on cdtor_returns_this arches (aka...
authorJakub Jelinek <jakub@redhat.com>
Fri, 23 Feb 2024 17:55:12 +0000 (18:55 +0100)
committerJakub Jelinek <jakub@redhat.com>
Fri, 23 Feb 2024 17:55:12 +0000 (18:55 +0100)
commitfdf9df9d55802e1d8ff0bd14585ea61b2bb9d798
tree2af8dfb3c157e5aa3ce4b83d73cc5c4afba26415
parentff442719cdb64c9df9d069af88e90d51bee6fb56
c++: Fix ICE due to folding a call to constructor on cdtor_returns_this arches (aka arm32) [PR113083]

When targetm.cxx.cdtor_returns_this () (aka on arm32 TARGET_AAPCS_BASED)
constructor is supposed to return this pointer, but when we cp_fold such
a call, we don't take that into account and just INIT_EXPR the object,
so we can later ICE during gimplification, because the expression doesn't
have the right type.

2024-02-23  Jakub Jelinek  <jakub@redhat.com>

PR c++/113083
* cp-gimplify.cc (cp_fold): For targetm.cxx.cdtor_returns_this ()
wrap r into a COMPOUND_EXPR and return folded CALL_EXPR_ARG (x, 0).

* g++.dg/cpp0x/constexpr-113083.C: New test.
gcc/cp/cp-gimplify.cc
gcc/testsuite/g++.dg/cpp0x/constexpr-113083.C [new file with mode: 0644]