diff options
author | Jakub Jelinek <jakub@redhat.com> | 2022-11-16 14:42:54 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2022-11-16 14:44:45 +0100 |
commit | cf958f8f168f695d49e29297ef9fb37f6efa5d0f (patch) | |
tree | 7347017f8bd4bb25b5722320294b2219474ff959 /libstdc++-v3/include/std | |
parent | 85966f0d20baf50a767ac1110f537395441604a9 (diff) | |
download | gcc-cf958f8f168f695d49e29297ef9fb37f6efa5d0f.zip gcc-cf958f8f168f695d49e29297ef9fb37f6efa5d0f.tar.gz gcc-cf958f8f168f695d49e29297ef9fb37f6efa5d0f.tar.bz2 |
c++: Fix up calls to static operator() or operator[] [PR107624]
One thing that doesn't work properly is the same problem as I've filed
yesterday for static operator() - PR107624 - that side-effects of
the postfix-expression on which the call or subscript operator are
applied are thrown away, I assume we have to add them into COMPOUND_EXPR
somewhere after we find out that the we've chosen a static member function
operator.
On Mon, Nov 14, 2022 at 06:29:44PM -0500, Jason Merrill wrote:
> Indeed. The code in build_new_method_call for this case has the comment
>
> /* In an expression of the form `a->f()' where `f' turns
> out to be a static member function, `a' is
> none-the-less evaluated. */
Had to tweak 3 spots for this. Furthermore, found that if in non-pedantic
C++20 compilation static operator[] is accepted, we required that it has 2
arguments, I think it is better to require exactly one because that case
is the only one that will actually work in C++20 and older.
2022-11-16 Jakub Jelinek <jakub@redhat.com>
PR c++/107624
* call.cc (keep_unused_object_arg): New function.
(build_op_call): Use it.
(build_op_subscript): Likewise.
(build_new_op): Similarly for ARRAY_REF.
(build_new_method_call): Use it.
* decl.cc (grok_op_properties): For C++20 and earlier, if operator[]
is static member function, require exactly one parameter rather than
exactly two parameters.
* g++.dg/cpp23/static-operator-call4.C: New test.
* g++.dg/cpp23/subscript10.C: New test.
* g++.dg/cpp23/subscript11.C: New test.
Diffstat (limited to 'libstdc++-v3/include/std')
0 files changed, 0 insertions, 0 deletions