diff options
author | Jakub Jelinek <jakub@redhat.com> | 2023-01-19 23:31:15 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2023-01-19 23:31:15 +0100 |
commit | 86caab6c5d1e26e1c54c3dceacc873d6e27bfc09 (patch) | |
tree | 1ceb7d654a64ea530709578cd1bbb50869c14394 /libbacktrace/dwarf.c | |
parent | 9b9a989adc042b304572fd6d4ade46b47be6ccb8 (diff) | |
download | gcc-86caab6c5d1e26e1c54c3dceacc873d6e27bfc09.zip gcc-86caab6c5d1e26e1c54c3dceacc873d6e27bfc09.tar.gz gcc-86caab6c5d1e26e1c54c3dceacc873d6e27bfc09.tar.bz2 |
c++: Fix up handling of non-dependent subscript with static operator[] [PR108437]
As the following testcases shows, when adding static operator[]
support I've missed that the 2 build_min_non_dep_op_overload functions
need to be adjusted. The first one we only use for the single index
case, but as cp_tree_code_length (ARRAY_REF) is 2, we were running
into an assertion there which compared nargs and expected_nargs.
For ARRAY_REF, the operator[] is either a non-static member or newly
static member, never out of class and for the static member case
if user uses single index the operator[] needs to have a single
argument as well, but the function is called with 2 - the object
it is invoked on and the index. We need to evaluate side-effects
of the object and use just a single argument in the call - the index.
The other build_min_non_dep_op_overload overload has been added
solely for ARRAY_REF - CALL_EXPR is the other operator that accepts
variable number of operands but that one goes through different
routines. There we asserted it is a METHOD_TYPE, so again
we shouldn't assert that but handle the case when it is not one
by making sure object's side-effects are evaluated if needed and
passing all the index arguments to the static operator[].
2023-01-19 Jakub Jelinek <jakub@redhat.com>
PR c++/108437
* cp-tree.h (keep_unused_object_arg): Declare.
* call.cc (keep_unused_object_arg): No longer static.
* tree.cc (build_min_non_dep_op_overload): Handle ARRAY_REF
with overload being static member function.
* g++.dg/cpp23/subscript12.C: New test.
* g++.dg/cpp23/subscript13.C: New test.
Diffstat (limited to 'libbacktrace/dwarf.c')
0 files changed, 0 insertions, 0 deletions