www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13895] New: Declaration grammar is insufficient

https://issues.dlang.org/show_bug.cgi?id=13895

          Issue ID: 13895
           Summary: Declaration grammar is insufficient
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: spec
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: briancschott gmail.com
            Blocks: 10233

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.

--
Dec 26 2014