> On Jun 16, 2023, at 3:21 AM, Martin Uecker <uec...@tugraz.at> wrote: > > Am Donnerstag, dem 15.06.2023 um 16:55 +0000 schrieb Joseph Myers: >> On Thu, 15 Jun 2023, Qing Zhao via Gcc-patches wrote: >> > ... >>> 1. Update the routine “c_parser_postfix_expression” (is this the right >>> place? ) to accept the new designator syntax. >> >> Any design that might work with an expression is the sort of thing that >> would likely involve many iterations on the specification (i.e. proposed >> wording changes to the C standard) for the interpretation of the new kinds >> of expressions, including how to resolve syntactic ambiguities and how >> name lookup works, before it could be considered ready to implement, and >> then a lot more work on the specification based on implementation >> experience. >> >> Note that no expressions can start with the '.' token at present. As soon >> as you invent a new kind of expression that can start with that token, you >> have syntactic ambiguity. >> >> struct s1 { int c; char a[(struct s2 { int c; char b[.c]; }) {.c=.c}.c]; }; >> >> Is ".c=.c" a use of the existing syntax for designated initializers, with >> the first ".c" being a designator and the second being a use of the new >> kind of expression, or is it an assignment expression, where both the LHS >> and the RHS of the assignment use the new kind of expression? And do >> those .c, when the use the new kind of expression, refer to the inner or >> outer struct definition? > > I would treat this is one integrated feature. Essentially .c is > somthing like this->c for the current struct for designated > initializer *and* size expressions because it is semantically > so close.
Yes, I think this is reasonable. (Is “this” the immediate containing structure?) > In the initializer I would allow only > the current use for designated initialization for all names of > member of the currently initialized struct, so .c = .c would > be invalid. Given “.c” basically is “this->c”, then .c = .c should be considered as this->c = this->c, is such self-initialization allowed in C? > It should never refer to the outer struct if there > is a member with the same name in the inner struct, i.e. the > outside member is then hidden. Does the above mean: if there is NO name conflicting, it could refer to a field of an outer struct? Why this is allowed? Why just disallow all referring to the field of the outer structure since .c basically is this->c? > > So this would be ok: > > struct s1 { int d; char a[(struct s2 { int c; char b[.c]; }) {.c=.d}.c]; }; > > Here the use of .d would be ok because it is not from the struct > currently initialized, but from an outside scope. I think that the above .c=.d should report an error, since .d does not exist in the containing structure. Do I miss anything here? thanks. Qing > > Martin > > > >