Bug 23716 – ImportC: Missing documentation on the asm keyword accepted as an extension

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
Linux
Creation time
2023-02-15T17:08:35Z
Last change time
2023-02-20T07:21:30Z
Keywords
accepts-invalid, ImportC, pull
Assigned to
No Owner
Creator
Iain Buclaw
Depends on
23689
See also
https://issues.dlang.org/show_bug.cgi?id=23689

Comments

Comment #0 by ibuclaw — 2023-02-15T17:08:35Z
When compiling the test with `gcc -std=c11 -fsyntax-only` compilable/testcstuff2.c:18:20: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘asm’ 18 | typedef int T21934 asm("realtype"); | ^~~ compilable/testcstuff2.c:19:15: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘asm’ 19 | int init21934 asm("realsym") = 1; | ^~~ compilable/testcstuff2.c:20:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘asm’ 20 | int var21934 asm("realvsym"); | ^~~ Original test case: ``` typedef int T21934 asm("realtype"); int init21934 asm("realsym") = 1; int var21934 asm("realvsym"); int fun21934() asm("realfun"); ```
Comment #1 by ibuclaw — 2023-02-15T17:24:25Z
Also: void test21934() { typedef int asmreg; register asmreg r1 asm("r1"); // asm ignored by C compiler, should be disallowed? asmreg r2 asm("r2"); register asmreg r3 asm("r3") = 3; // asm ignored by C compiler, should be disallowed? asmreg r4 asm("r4") = 4; }
Comment #2 by ibuclaw — 2023-02-15T17:57:27Z
More errors: runnable/test23011.c:7:25: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘asm’ 7 | extern char **myenviron asm("environ"); | ^~~ runnable/test23011.c:8:27: error: expected declaration specifiers before ‘asm’ 8 | int myprintf(char *, ...) asm("printf"); | ^~~ runnable/test23347.c:12:14: error: expected declaration specifiers before ‘asm’ 12 | void spoon() asm("fork"); | ^~~
Comment #3 by dlang-bot — 2023-02-15T21:31:45Z
@ibuclaw created dlang/dlang.org pull request #3530 "fix Issue 23716 - Document asm extension for ImportC" fixing this issue: - fix Issue 23716 - Document asm extension for ImportC https://github.com/dlang/dlang.org/pull/3530
Comment #4 by ibuclaw — 2023-02-15T21:33:36Z
`asm` is a GNU extension, and errors go away if instead compiling with `-std=gnu11`. However that this is an extension is not documented on the dlang.org spec pages.
Comment #5 by dlang-bot — 2023-02-20T07:21:30Z
dlang/dlang.org pull request #3530 "fix Issue 23716 - Document asm extension for ImportC" was merged into master: - 55d75043cd77401048f6d3a9a24db317bf9dde02 by Iain Buclaw: fix Issue 23716 - Document asm extension for ImportC https://github.com/dlang/dlang.org/pull/3530