Allow "stock static" in addition to "static stock".
This commit is contained in:
parent
3e012e7f79
commit
491036a1e6
@ -1445,12 +1445,25 @@ static void dodecl(const token_t *tok)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fpublic = (tok->id == tPUBLIC);
|
int fpublic = FALSE, fstock = FALSE, fstatic = FALSE, fconst = FALSE;
|
||||||
int fstock = (tok->id == tSTOCK);
|
switch (tok->id) {
|
||||||
int fstatic = (tok->id == tSTATIC);
|
case tPUBLIC:
|
||||||
|
fpublic = TRUE;
|
||||||
|
break;
|
||||||
|
case tSTOCK:
|
||||||
|
fstock = TRUE;
|
||||||
|
if (matchtoken(tSTATIC))
|
||||||
|
fstatic = TRUE;
|
||||||
|
break;
|
||||||
|
case tSTATIC:
|
||||||
|
fstatic = TRUE;
|
||||||
|
|
||||||
if (fstatic && matchtoken(tSTOCK))
|
// For compatibility, we must include this case. Though "stock" should
|
||||||
fstock = TRUE;
|
// come first.
|
||||||
|
if (matchtoken(tSTOCK))
|
||||||
|
fstock = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
int flags = DECLFLAG_MAYBE_FUNCTION | DECLFLAG_VARIABLE | DECLFLAG_ENUMROOT;
|
int flags = DECLFLAG_MAYBE_FUNCTION | DECLFLAG_VARIABLE | DECLFLAG_ENUMROOT;
|
||||||
if (tok->id == tNEW)
|
if (tok->id == tNEW)
|
||||||
@ -1462,7 +1475,13 @@ static void dodecl(const token_t *tok)
|
|||||||
decl.type.tag = 0;
|
decl.type.tag = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!decl.opertok && (tok->id == tNEW || decl.type.has_postdims || !lexpeek('('))) {
|
// Hacky bag o' hints as to whether this is a variable decl.
|
||||||
|
bool probablyVariable = tok->id == tNEW ||
|
||||||
|
decl.type.has_postdims ||
|
||||||
|
!lexpeek('(') ||
|
||||||
|
((decl.type.usage & uCONST) == uCONST);
|
||||||
|
|
||||||
|
if (!decl.opertok && probablyVariable) {
|
||||||
if (tok->id == tNEW && decl.type.is_new)
|
if (tok->id == tNEW && decl.type.is_new)
|
||||||
error(143);
|
error(143);
|
||||||
if (decl.type.tag & STRUCTTAG) {
|
if (decl.type.tag & STRUCTTAG) {
|
||||||
|
5
sourcepawn/compiler/tests/ok-static-stocks-1.sp
Normal file
5
sourcepawn/compiler/tests/ok-static-stocks-1.sp
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
static stock const X = 5;
|
||||||
|
stock static const Y = 6;
|
||||||
|
|
||||||
|
public main()
|
||||||
|
{}
|
7
sourcepawn/compiler/tests/ok-static-stocks-2.sp
Normal file
7
sourcepawn/compiler/tests/ok-static-stocks-2.sp
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
static stock const X = 5;
|
||||||
|
stock static const Y = 6;
|
||||||
|
|
||||||
|
public main()
|
||||||
|
{
|
||||||
|
return X + Y;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user