Bug 13895 – Declaration grammar is insufficient

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-12-26T08:45:00Z
Last change time
2015-01-08T01:22:23Z
Keywords
pull, spec
Assigned to
nobody
Creator
briancschott
Blocks
10233

Comments

Comment #0 by briancschott — 2014-12-26T08:45:33Z
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
Comment #2 by k.hara.pg — 2014-12-27T14:36:15Z
Comment #3 by github-bugzilla — 2015-01-08T01:22:23Z
Commits pushed to master at https://github.com/D-Programming-Language/dlang.org https://github.com/D-Programming-Language/dlang.org/commit/16957d1ce071c478206f963c1352a7c8ed943960 fix Issue 13895 - Declaration grammar is insufficient https://github.com/D-Programming-Language/dlang.org/commit/7ffcabd0159e47527d2808446d0ba2141ea5f91e Merge pull request #728 from 9rnsr/fix13895 Issue 13895 - Declaration grammar is insufficient