Bug 24154 – ImportC: useless expression parsed as invalid variable declaration

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-09-24T01:35:57Z
Last change time
2023-09-30T16:13:43Z
Keywords
ImportC, pull
Assigned to
No Owner
Creator
dave287091

Comments

Comment #0 by dave287091 — 2023-09-24T01:35:57Z
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