On Mon, May 18, 2020 at 04:50:44PM -0400, Jason Merrill via Gcc-patches wrote:
> On 5/13/20 12:22 PM, Marek Polacek wrote:
> > 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
> 
> Why isn't it?  I see
> 
>   cp_declarator *declarator = make_declarator (cdk_decomp);
> 
> a few lines up.

Right, and we use that for the underlying decomp base VAR_DECL.  But each of
the named variables used in a structured binding are created in the
FOR_EACH_VEC_ELT loop, and that creates a cdk_id declarator for them:

13963       if (i == 0)
13964         declarator = make_id_declarator (NULL_TREE, e.get_value (),
13965                                          sfk_none, e.get_location ());


Marek

Reply via email to