KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am having an issue with wrapping my head around an apparent ambiguity in the c++0x spec, see also: http://www.nongnu.org/hcb/ Assume we have the code void foo() {}; Personally I interpret the code as a function-definition followed by an empty-declaration . But, looking at the grammar spec, I'd say that this could just as easily be interpreted as a simple-declaration , which is part of block-declaration and hence mentioned sooner in the list of declaration ... Here's my explanation for how this can be parsed as a simple-declaration: void foo() {};" -> simple-declaration void -> decl-specifier-seq -> decl-specifier -> type-specifier -> trailing-type- specifier -> simple-type-specifier foo() {} -> init declarator-list -> init-declarator foo() -> declarator -> ptr-declarator -> noptr-declarator foo -> declarator-id -> ... () -> parameters-and-qualifiers {} -> initializer -> braced-init-list So this should be possible to be parsed as a simple-declaration. I was told that 6.8 of the spec should be used to disambiguate this case, but I don't quite understand why. Is a simple-declaration an expression-statement since it ends with an ; ?
Tags (comma-separated)
Save Edits
Cancel