Bug 22560 – ImportC: extra semicolon not allowed outside of functions

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-12-03T01:01:34Z
Last change time
2021-12-14T10:34:32Z
Keywords
ImportC, pull
Assigned to
No Owner
Creator
dave287091

Comments

Comment #0 by dave287091 — 2021-12-03T01:01:34Z
Compilation fails if an extra semicolon is encountered outside of a function. For example: // semi.c ; // semi.c(1): Error: identifier or `(` expected int main(){return 0;} This is technically correct, but sometimes headers end up with extra semicolons at file scope after pre-processing if conditional type declarations are incorrectly guarded. For example, a header might use a function-like macro to declare a type, conditionally defining it to expand to nothing. Then they incorrectly put a semicolon after the function like macro. For example: #if SOME_CONDITION #define DECLARE(name) struct name #else #define DECLARE(name) #endif DECLARE(name); // this semicolon is incorrect if SOME_CONDITION is false Some headers on macOS have this incorrect pattern. GCC and clang both allow the extra semicolon at file scope.
Comment #1 by dlang-bot — 2021-12-05T07:45:02Z
@WalterBright created dlang/dmd pull request #13385 "fix Issue 22560 - ImportC: extra semicolon not allowed outside of fun…" fixing this issue: - fix Issue 22560 - ImportC: extra semicolon not allowed outside of functions https://github.com/dlang/dmd/pull/13385
Comment #2 by dlang-bot — 2021-12-05T09:30:34Z
dlang/dmd pull request #13385 "fix Issue 22560 - ImportC: extra semicolon not allowed outside of fun…" was merged into stable: - cf325801fe4bfe23e3ea540cdbb9164d3049a832 by Walter Bright: fix Issue 22560 - ImportC: extra semicolon not allowed outside of functions https://github.com/dlang/dmd/pull/13385
Comment #3 by dlang-bot — 2021-12-14T10:34:32Z
dlang/dmd pull request #13421 "merge stable" was merged into master: - 3cfee53f192f71f4f6d4c40b9658ec26559cae62 by Walter Bright: fix Issue 22560 - ImportC: extra semicolon not allowed outside of functions https://github.com/dlang/dmd/pull/13421