]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Fix up ICE in build_min_non_dep_op_overload [PR109319]
authorJakub Jelinek <jakub@redhat.com>
Thu, 30 Mar 2023 21:08:25 +0000 (23:08 +0200)
committerJakub Jelinek <jakub@redhat.com>
Tue, 18 Apr 2023 07:15:21 +0000 (09:15 +0200)
commit6a5c0588ac00f6f55ae7ed2bb791e7e119a01c43
treef1bfa9ac0a5c68260f77545c5bdde6f1c5428d1a
parent2d96422f4608c04d6a7c8444f14446c309416e24
c++: Fix up ICE in build_min_non_dep_op_overload [PR109319]

The following testcase ICEs, because grok_array_decl during
processing_template_decl handling of a non-dependent subscript
emits a -Wcomma-subscript pedwarn, we decide to pass to the
single index argument the index expressions as if it was wrapped
with () around it, but then when preparing it for later instantiation
we don't actually take that into account and ICE on a mismatch of
number of index arguments (the overload expects a single index,
testcase has two index expressions in this case).
For non-dependent subscript which are builtin subscripts we also
emit the same pedwarn and don't ICE, but emit the same pedwarn
again whenever we instantiate it, which is also IMHO undesirable,
it is enough to warn once during parsing the template.

The following patch fixes it by turning even the original index expressions
(those which didn't go through make_args_non_dependent) into a single
index using comma expression(s).

2023-03-30  Jakub Jelinek  <jakub@redhat.com>

PR c++/109319
* decl2.cc (grok_array_decl): After emitting a pedwarn for
-Wcomma-subscript, if processing_template_decl set orig_index_exp
to compound expr from orig_index_exp_list.

* g++.dg/cpp23/subscript14.C: New test.

(cherry picked from commit c016887c91a79d67b6a3c7e19b9219f5ab1e2a4d)
gcc/cp/decl2.cc
gcc/testsuite/g++.dg/cpp23/subscript14.C [new file with mode: 0644]