Skip to content

Commit

Permalink
Fix bugzilla 24580 - ImportC: Asm label after attributes results in s…
Browse files Browse the repository at this point in the history
…yntax error
  • Loading branch information
tim-dlang authored and dlang-bot committed Jun 8, 2024
1 parent a903c10 commit db92f68
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
28 changes: 18 additions & 10 deletions compiler/src/dmd/cparse.d
Original file line number Diff line number Diff line change
Expand Up @@ -1872,22 +1872,30 @@ final class CParser(AST) : Parser!AST
* init-declarator:
* declarator simple-asm-expr (opt) gnu-attributes (opt)
* declarator simple-asm-expr (opt) gnu-attributes (opt) = initializer
*
* Clang also allows simple-asm-expr after gnu-attributes.
*/
while (1)
{
if (token.value == TOK.asm_)
{
asmName = cparseGnuAsmLabel();
/* This is a data definition, there cannot now be a
* function definition.
*/
first = false;
}
else if (token.value == TOK.__attribute__)
cparseGnuAttributes(specifier);
else
break;
}

switch (token.value)
{
case TOK.assign:
case TOK.comma:
case TOK.semicolon:
case TOK.asm_:
case TOK.__attribute__:
if (token.value == TOK.asm_)
asmName = cparseGnuAsmLabel();
if (token.value == TOK.__attribute__)
{
cparseGnuAttributes(specifier);
if (token.value == TOK.leftCurly)
break; // function definition
}
/* This is a data definition, there cannot now be a
* function definition.
*/
Expand Down
5 changes: 5 additions & 0 deletions compiler/test/compilable/testcstuff2.c
Original file line number Diff line number Diff line change
Expand Up @@ -758,3 +758,8 @@ typedef enum
DISPLAYCONFIG_OUTPUT_TECHNOLOGY_SVIDEO = 1,
DISPLAYCONFIG_OUTPUT_TECHNOLOGY_INTERNAL = 0x80000000,
} DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY;

/************************************************************/
// https://issues.dlang.org/show_bug.cgi?id=24580

int ioctl(int __fd, unsigned __request, ...) __attribute__((overloadable)) __attribute__((enable_if(1, ""))) asm("ioctl");

0 comments on commit db92f68

Please sign in to comment.