diff options
author | Jakub Jelinek <jakub@redhat.com> | 2025-07-08 19:21:55 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2025-07-08 19:21:55 +0200 |
commit | c81447d969f27a8653ebb1a450372f0d25a2e628 (patch) | |
tree | 47b32c8d11752a590282b4559f2d27676c53e799 /libcpp/errors.cc | |
parent | 70bd97e89ddf8fcb8c14e84a8fd580404536eeb1 (diff) | |
download | gcc-c81447d969f27a8653ebb1a450372f0d25a2e628.zip gcc-c81447d969f27a8653ebb1a450372f0d25a2e628.tar.gz gcc-c81447d969f27a8653ebb1a450372f0d25a2e628.tar.bz2 |
c++: Implement part of C++26 P2686R4 - constexpr structured bindings [PR117784]
The following patch implements the constexpr structured bindings part of
the P2686R4 paper, so the [dcl.pre], [dcl.struct.bind], [dcl.constinit]
and first hunk in [dcl.constexpr] changes.
The paper doesn't have a feature test macro and the constexpr structured
binding part of it seems more-less self-contained, so I think it is useful
to get this in independently from the rest.
Of course, automatic constexpr/constinit structured bindings in the
tuple cases or automatic constexpr/constinit structured bindings with auto &
will not really work for now.
Another reason for the split is that for C++ < 26, I think what the patch
implements is basically what the users will see, i.e. we can accept
constexpr or constinit structured binding with pedwarn, but I think we can't
change the constant expression rules in C++ < 26.
I plan to look at the rest of the paper.
2025-07-08 Jakub Jelinek <jakub@redhat.com>
PR c++/117784
* decl.cc: Implement part of C++26 P2686R4 - constexpr structured
bindings.
(cp_finish_decl): Pedwarn for C++23 and older on constinit on
structured bindings except for static/thread_local where it uses
earlier error.
(grokdeclarator): Pedwarn on constexpr structured bindings for
C++23 and older instead of emitting error always, don't clear
constexpr_p in that case.
* parser.cc (cp_parser_decomposition_declaration): Copy over
DECL_DECLARED_CONSTEXPR_P and DECL_DECLARED_CONSTINIT_P flags.
* g++.dg/cpp1z/decomp3.C (test): For constexpr structured binding
initialize from constexpr var instead of non-constexpr and expect
just a pedwarn for C++23 and older instead of error always.
* g++.dg/cpp26/decomp9.C (foo): Likewise.
* g++.dg/cpp26/decomp22.C: New test.
* g++.dg/cpp26/decomp23.C: New test.
* g++.dg/cpp26/decomp24.C: New test.
* g++.dg/cpp26/decomp25.C: New test.
Diffstat (limited to 'libcpp/errors.cc')
0 files changed, 0 insertions, 0 deletions