eliben / pycparser

:snake: Complete C99 parser in pure Python
Other
3.26k stars 612 forks source link

Named initializer AST is ambiguous for [ENUMERATOR] = ... vs .prop = ... #466

Open simonlindholm opened 2 years ago

simonlindholm commented 2 years ago
struct A { int x; };
struct A a = {
    .x = 1
};

and

enum { x };
int a[] = {
    [x] = 1
};

both result in a Decl with

init=InitList(exprs=[NamedInitializer(name=[ID(name='x')],
                                      expr=Constant(type='int', value='1'))]),

(The serializer choses to emit .x = 1 in this case.)