The pragma in this code:
void foo(){pragma(bar);}
Is seen by the front-end as a statement (verified by putting some printf...).
According to the specifications:
- we're in a block so we have either DeclarationOrStatement s inside.
- "pragma(bar);" matches to the attribute declaration rule.
- "pragma(bar);" matches to the PragmaStatement rule too.
in http://dlang.org/spec/statement.html, just after the grammar table we can read:
"Any ambiguities in the grammar between Statements and Declarations are resolved by the declarations taking precedence".
By applying this rule of thumb, the front-end should rather see "pragma(bar);" as a declaration.
Comment #1 by dfj1esp02 — 2017-07-12T13:24:26Z
This can't be a declaration, because empty declaration can't have attributes:
---
static;
---
Error: declaration expected following attribute, not ';'
Comment #2 by iamthewilsonator — 2018-08-28T03:21:21Z
*** Issue 19149 has been marked as a duplicate of this issue. ***
Comment #3 by iamthewilsonator — 2018-08-28T03:23:46Z
void main(){
pragma(mangle, "aaa") __gshared int a = 1; // Is a declaration, incorrectly marked as a pragma statement.
}
see issue 19149.
Comment #4 by b2.temp — 2023-09-07T00:29:25Z
*** This issue has been marked as a duplicate of issue 22682 ***