diff options
author | Marek Polacek <polacek@redhat.com> | 2020-05-19 23:53:28 -0400 |
---|---|---|
committer | Marek Polacek <polacek@redhat.com> | 2020-05-20 13:35:09 -0400 |
commit | 2a8565fa1182ed326721a50c700f9f5275355d40 (patch) | |
tree | 5262a6749e233eacb317bbb259ac1e4c6d577f60 /gcc/cp/expr.c | |
parent | 3872a519c8fa65318efa1b481d331ef91b3ff044 (diff) | |
download | gcc-2a8565fa1182ed326721a50c700f9f5275355d40.zip gcc-2a8565fa1182ed326721a50c700f9f5275355d40.tar.gz gcc-2a8565fa1182ed326721a50c700f9f5275355d40.tar.bz2 |
c++: Implement DR 2289, Uniqueness of structured binding names [PR94553]
DR 2289 clarified that since structured bindings have no C compatibility
implications, they should be unique in their declarative region, see
[basic.scope.declarative]/4.2.
The duplicate_decls hunk is the gist of the patch, but that alone would
not be enough to detect the 'A' case: cp_parser_decomposition_declaration
uses
13968 tree decl2 = start_decl (declarator, &decl_specs, SD_INITIALIZED,
13969 NULL_TREE, NULL_TREE, &elt_pushed_scope);
to create the 'A' VAR_DECL but in this start_decl's grokdeclarator we
don't do fit_decomposition_lang_decl because the declarator kind is not
cdk_decomp, so then when start_decl calls maybe_push_decl, the decl 'A'
isn't DECL_DECOMPOSITION_P and we don't detect this case. So I needed a
way to signal to start_decl that it should fit_decomposition_lang_decl.
In this patch, I'm adding SD_DECOMPOSITION flag to say that the variable
is initialized and it should also be marked as DECL_DECOMPOSITION_P.
DR 2289
PR c++/94553
* cp-tree.h (SD_DECOMPOSITION): New flag.
* decl.c (duplicate_decls): Make sure a structured binding is unique
in its declarative region.
(start_decl): If INITIALIZED is SD_DECOMPOSITION, call
fit_decomposition_lang_decl.
(grokdeclarator): Compare INITIALIZED directly to SD_* flags.
* parser.c (cp_parser_decomposition_declaration): Pass SD_DECOMPOSITION
to start_decl.
* g++.dg/cpp1z/decomp52.C: New test.
Diffstat (limited to 'gcc/cp/expr.c')
0 files changed, 0 insertions, 0 deletions