diff --git a/compiler/src/dmd/cparse.d b/compiler/src/dmd/cparse.d index 1b3f36d654ba..9fc4bf570034 100644 --- a/compiler/src/dmd/cparse.d +++ b/compiler/src/dmd/cparse.d @@ -3298,8 +3298,10 @@ final class CParser(AST) : Parser!AST nextToken(); else { - error("extended-decl-modifier expected"); - break; + error("extended-decl-modifier expected after `__declspec(`, saw `%s` instead", token.toChars()); + nextToken(); + if (token.value != TOK.rightParenthesis) + break; } } } diff --git a/compiler/test/fail_compilation/msg24094.c b/compiler/test/fail_compilation/msg24094.c new file mode 100644 index 000000000000..56747b0ea5f9 --- /dev/null +++ b/compiler/test/fail_compilation/msg24094.c @@ -0,0 +1,7 @@ +/* TEST_OUTPUT: +--- +fail_compilation/msg24094.c(7): Error: extended-decl-modifier expected after `__declspec(`, saw `*` instead +--- +*/ + +__declspec(*) void* __cdecl _calloc_base(int, int);