Revert 3336, try fix #2 (
bug 4852, r=dvander)
1.1 --- a/sourcepawn/compiler/sc.h Fri Jul 08 07:55:20 2011 -0400
1.2 +++ b/sourcepawn/compiler/sc.h Sat Jul 09 20:47:43 2011 -0700
1.3 @@ -386,6 +386,7 @@
1.4 #define tSTRING 340
1.5 #define tEXPR 341 /* for assigment to "lastst" only (see SC1.C) */
1.6 #define tENDLESS 342 /* endless loop, for assigment to "lastst" only */
1.7 +#define tEMPTYBLOCK 343 /* empty blocks for AM bug 4825 */
1.8
1.9 /* (reversed) evaluation of staging buffer */
1.10 #define sSTARTREORDER 0x01
2.1 --- a/sourcepawn/compiler/sc1.c Fri Jul 08 07:55:20 2011 -0400
2.2 +++ b/sourcepawn/compiler/sc1.c Sat Jul 09 20:47:43 2011 -0700
2.3 @@ -5660,9 +5660,13 @@
2.4 case '{':
2.5 case tBEGIN:
2.6 save=fline;
2.7 - if (!matchtoken('}')) /* {} is the empty statement */
2.8 + if (!matchtoken('}')) { /* {} is the empty statement */
2.9 compound(save==fline,tok);
2.10 - /* lastst (for "last statement") does not change */
2.11 + } else {
2.12 + lastst = tEMPTYBLOCK;
2.13 + }
2.14 + /* lastst (for "last statement") does not change
2.15 + you're not my father, don't tell me what to do */
2.16 break;
2.17 case ';':
2.18 error(36); /* empty statement */
2.19 @@ -5990,6 +5994,12 @@
2.20 setlabel(flab1); /* print false label */
2.21 statement(NULL,FALSE); /* do "else" clause */
2.22 setlabel(flab2); /* print true label */
2.23 + /* if both the "true" branch and the "false" branch ended with the same
2.24 + * kind of statement, set the last statement id to that kind, rather than
2.25 + * to the generic tIF; this allows for better "unreachable code" checking
2.26 + */
2.27 + if (lastst==lastst_true)
2.28 + return lastst;
2.29 } /* if */
2.30 return tIF;
2.31 }