[dmd-internals] Why do AttribDeclarations exist?

Don Clugston dclugston at googlemail.com
Fri Feb 17 00:48:49 PST 2012


I found this why looking at bug 7482, and it seems to be a fundamental
problem. Surely other people have hit this before.

Something like:
deprecated int x;
is parsed as  StorageDeclaration( STCdeprecated, new VarDeclaration(x))

note that the VarDeclaration is initially created without the
'deprecated' storage class.
Then, when semantic is run on all the declarations in the module, it
runs on StorageDeclaration, which then runs semanticNewSc on the
VarDeclaration.

The problem is, if 'x' is forward referenced, the storage declaration
hasn't run yet. It gets found with the original, wrong storage class.
I don't understand why these AttribDeclarations exist at all. Why
isn't the whole thing dealt with in the parser?

(ie, create a PendingAttribs struct, and pass it to all the children
in a block).


More information about the dmd-internals mailing list