Skip to content

Commit

Permalink
fix Issue 22666 - ImportC: Error: attributes should be specified befo…
Browse files Browse the repository at this point in the history
…re the function definition
  • Loading branch information
WalterBright committed Jan 13, 2022
1 parent 14b9c01 commit 5d0fd73
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
18 changes: 5 additions & 13 deletions src/dmd/cparse.d
Expand Up @@ -1550,26 +1550,18 @@ final class CParser(AST) : Parser!AST
case TOK.semicolon:
case TOK.asm_:
case TOK.__attribute__:
/* This is a data definition, there cannot now be a
* function definition.
*/
first = false;
if (token.value == TOK.asm_)
asmname = cparseSimpleAsmExpr();
if (token.value == TOK.__attribute__)
{
cparseGnuAttributes(specifier);
if (token.value == TOK.leftCurly)
{
error("attributes should be specified before the function definition");
auto t = &token;
if (skipBraces(t))
{
token = *t;
return;
}
}
break; // function definition
}
/* This is a data definition, there cannot now be a
* function definition.
*/
first = false;
break;

default:
Expand Down
1 change: 0 additions & 1 deletion test/fail_compilation/failcstuff1.c
@@ -1,7 +1,6 @@
// check the expression parser
/* TEST_OUTPUT
---
fail_compilation/failcstuff1.c(51): Error: attributes should be specified before the function definition
fail_compilation/failcstuff1.c(100): Error: no members for `enum E21962`
fail_compilation/failcstuff1.c(101): Error: no members for anonymous enum
fail_compilation/failcstuff1.c(152): Error: `;` or `,` expected
Expand Down

0 comments on commit 5d0fd73

Please sign in to comment.