ImportC is unable to parse a “useless” expression statement:
int main(){
int x = 3;
x; // Error: type-specifier missing for declaration of `x`
return x;
}
This almost never comes up in normal code, but when using gnu statement expressions, the last expression in the statement expression is the value of the statement expression and so is often one of these “useless” statements:
int main(){
int x = ({
int ret;
ret = 3;
ret; // Error: type-specifier missing for declaration of `ret`
});
return x;
}
The arm_neon.h header has many statement expressions like this.
Comment #1 by dlang-bot — 2023-09-30T05:45:52Z
@WalterBright created dlang/dmd pull request #15639 "fix Issue 24154 - ImportC: useless expression parsed as invalid varia…" fixing this issue:
- fix Issue 24154 - ImportC: useless expression parsed as invalid variable declaration
https://github.com/dlang/dmd/pull/15639
Comment #2 by dlang-bot — 2023-09-30T16:13:43Z
dlang/dmd pull request #15639 "fix Issue 24154 - ImportC: useless expression parsed as invalid varia…" was merged into master:
- 17a2baa53f57fb2755dd195addfca09976bd3379 by Walter Bright:
fix Issue 24154 - ImportC: useless expression parsed as invalid variable declaration
https://github.com/dlang/dmd/pull/15639