mirror of
https://github.com/dlang/dmd.git
synced 2025-04-27 21:51:03 +03:00
Fix Issue 4663 - Wrong 'static' position error message (#15321)
Also detects `extern`, `deprecated`, `ref`, `override` and friends.
This commit is contained in:
parent
342a226833
commit
7643dc6041
2 changed files with 30 additions and 0 deletions
|
@ -1405,6 +1405,15 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
Token* tk;
|
||||||
|
if (skipAttributes(&token, &tk) && tk.ptr != token.ptr ||
|
||||||
|
token.value == TOK.static_ || token.value == TOK.extern_)
|
||||||
|
{
|
||||||
|
error("`%s` token is not allowed in postfix position",
|
||||||
|
Token.toChars(token.value));
|
||||||
|
nextToken();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
return storageClass;
|
return storageClass;
|
||||||
}
|
}
|
||||||
storageClass = appendStorageClass(storageClass, stc);
|
storageClass = appendStorageClass(storageClass, stc);
|
||||||
|
|
21
compiler/test/fail_compilation/funcpostattr.d
Normal file
21
compiler/test/fail_compilation/funcpostattr.d
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
/*
|
||||||
|
TEST_OUTPUT:
|
||||||
|
---
|
||||||
|
fail_compilation/funcpostattr.d(11): Error: `deprecated` token is not allowed in postfix position
|
||||||
|
fail_compilation/funcpostattr.d(11): Error: `extern` token is not allowed in postfix position
|
||||||
|
fail_compilation/funcpostattr.d(15): Error: `static` token is not allowed in postfix position
|
||||||
|
fail_compilation/funcpostattr.d(15): Error: `ref` token is not allowed in postfix position
|
||||||
|
fail_compilation/funcpostattr.d(20): Error: `override` token is not allowed in postfix position
|
||||||
|
---
|
||||||
|
*/
|
||||||
|
void foo() deprecated extern;
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
int i;
|
||||||
|
int foo() static ref => i;
|
||||||
|
}
|
||||||
|
|
||||||
|
class C
|
||||||
|
{
|
||||||
|
void foo() override {}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue