Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Issue 22666 - ImportC: Error: attributes should be specified befo… #13521

Merged
merged 1 commit into from Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
WalterBright marked this conversation as resolved.
Show resolved Hide resolved
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