]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: constexpr ctor with RANGE_EXPR index [PR95241]
authorPatrick Palka <ppalka@redhat.com>
Fri, 29 May 2020 13:44:09 +0000 (09:44 -0400)
committerPatrick Palka <ppalka@redhat.com>
Sat, 30 May 2020 04:18:38 +0000 (00:18 -0400)
commit798a9da416bbfd8996da9a5d53955b082d5b94fe
tree7e9a3befa679fdd1c2f9cd011de5b26392d41986
parent9e81c820a3e48ead478dabbd6988482747f7a521
c++: constexpr ctor with RANGE_EXPR index [PR95241]

In the testcase below, the CONSTRUCTOR for 'field' contains a RANGE_EXPR
index:

  {{aggr_init_expr<...>, [1...2]={.off=1}}}

but get_or_insert_ctor_field isn't prepared to handle looking up a
RANGE_EXPR index.

This patch adds limited support to get_or_insert_ctor_field for looking
up a RANGE_EXPR index.  The limited scope of this patch should make it
more suitable for backporting, and more extensive support would be
needed only to handle self-modifying CONSTRUCTORs that contain a
RANGE_EXPR index, but I haven't yet been able to come up with a testcase
that actually creates such a CONSTRUCTOR.

gcc/cp/ChangeLog:

PR c++/95241
* constexpr.c (get_or_insert_ctor_field): Add limited support
for RANGE_EXPR index lookups.

gcc/testsuite/ChangeLog:

PR c++/95241
* g++.dg/cpp0x/constexpr-array25.C: New test.

(cherry picked from commit e069285cdf457cc85070e522380c4e25b0d2ed25)
gcc/cp/constexpr.c
gcc/testsuite/g++.dg/cpp0x/constexpr-array25.C [new file with mode: 0644]