]> gcc.gnu.org Git - gcc.git/commit
c++: Implement C++23 P2589R1 - - static operator[]
authorJakub Jelinek <jakub@redhat.com>
Tue, 15 Nov 2022 07:00:21 +0000 (08:00 +0100)
committerJakub Jelinek <jakub@redhat.com>
Tue, 15 Nov 2022 07:00:21 +0000 (08:00 +0100)
commit6492cec069bccf817ac5e984fb3eca407056a566
treefefcbffd560982373a49d8a1a6b0b9c119bd20c6
parente0f4fcf9dfb8794a11d4ee63899b820aa9257f50
c++: Implement C++23 P2589R1 - - static operator[]

Here is a patch that implements the static operator[] paper.
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.

2022-11-15  Jakub Jelinek  <jakub@redhat.com>

gcc/c-family/
* c-cppbuiltin.cc (c_cpp_builtins): Bump C++23
__cpp_multidimensional_subscript macro value to 202211L.
gcc/cp/
* decl.cc (grok_op_properties): Implement C++23 P2589R1
- static operator[].  Handle operator[] similarly to operator()
- allow static member functions, but pedwarn on it for C++20 and
older.  Unlike operator(), perform rest of checks on it though for
C++20.
* call.cc (add_operator_candidates): For operator[] with class
typed first parameter, pass that parameter as first_arg and
an adjusted arglist without that parameter.
gcc/testsuite/
* g++.dg/cpp23/subscript9.C: New test.
* g++.dg/cpp23/feat-cxx2b.C: Expect a newer
__cpp_multidimensional_subscript value.
* g++.old-deja/g++.bugs/900210_10.C: Don't expect an error
for C++23 or later.
gcc/c-family/c-cppbuiltin.cc
gcc/cp/call.cc
gcc/cp/decl.cc
gcc/testsuite/g++.dg/cpp23/feat-cxx2b.C
gcc/testsuite/g++.dg/cpp23/subscript9.C [new file with mode: 0644]
gcc/testsuite/g++.old-deja/g++.bugs/900210_10.C
This page took 0.059672 seconds and 5 git commands to generate.