Consider the following code (which is accepted by DMD):
---
void main()
{
abstract class C {}
}
---
This produces the parse tree:
...
NonEmptyStatementNoCaseNoDefault
DeclarationStatement
Declaration
???
AggregateDeclaration
ClassDeclaration
....
The problem is that there is no grammar rule stating that "abstract" is valid at that location, though it obviously is and should be.
Adding "StorageClasses(opt)" to AggregateDeclaration, or to ClassDeclaration, InterfaceDeclaration, StructDeclaration, and UnionDeclaration should fix this.
Comment #1 by k.hara.pg — 2014-12-27T14:34:13Z
(In reply to briancschott from comment #0)
> Adding "StorageClasses(opt)" to AggregateDeclaration, or to
> ClassDeclaration, InterfaceDeclaration, StructDeclaration, and
> UnionDeclaration should fix this.
It's an issue only in the declarations in statement level. If an aggregate declaration is placed in module level scope, there's no issue.
So, I think it would be the easiest fixing the grammar DeclarationStatement as follows:
DeclarationStatement:
StorageClasses(opt) Declaration