Fix bug in newdecls in for loop initializers.
This commit is contained in:
parent
680a8e0283
commit
bfc65b086a
@ -6965,6 +6965,28 @@ static int dofor(void)
|
||||
autozero=1;
|
||||
declloc(tok.id); /* declare local variable */
|
||||
break;
|
||||
case tSYMBOL:
|
||||
{
|
||||
// See comment in statement() near tSYMBOL.
|
||||
int is_decl = FALSE;
|
||||
if (matchtoken('[')) {
|
||||
if (lexpeek(']'))
|
||||
is_decl = TRUE;
|
||||
lexpush();
|
||||
} else if (lexpeek(tSYMBOL)) {
|
||||
is_decl = TRUE;
|
||||
}
|
||||
|
||||
if (is_decl) {
|
||||
lexpush();
|
||||
nestlevel++;
|
||||
autozero=1;
|
||||
declloc(tSYMBOL);
|
||||
break;
|
||||
}
|
||||
|
||||
// Fall-through to default!
|
||||
}
|
||||
default:
|
||||
lexpush();
|
||||
doexpr(TRUE,TRUE,TRUE,TRUE,NULL,NULL,FALSE); /* expression 1 */
|
||||
|
5
sourcepawn/compiler/tests/ok-for-newdecl.sp
Normal file
5
sourcepawn/compiler/tests/ok-for-newdecl.sp
Normal file
@ -0,0 +1,5 @@
|
||||
public OnPluginStart()
|
||||
{
|
||||
for (bool x; x;) {
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user