From 4d52fe0490c1b0121f9bf8359c8345681fcf248a Mon Sep 17 00:00:00 2001
From: Fyren <fyrenmoo@gmail.com>
Date: Sat, 9 Jul 2011 20:47:43 -0700
Subject: [PATCH] Revert 3336, try fix #2 (bug 4852, r=dvander)

---
 sourcepawn/compiler/sc.h  |  1 +
 sourcepawn/compiler/sc1.c | 14 ++++++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/sourcepawn/compiler/sc.h b/sourcepawn/compiler/sc.h
index 0caca49b..5b53125a 100644
--- a/sourcepawn/compiler/sc.h
+++ b/sourcepawn/compiler/sc.h
@@ -386,6 +386,7 @@ typedef struct s_stringpair {
 #define tSTRING  340
 #define tEXPR    341 /* for assigment to "lastst" only (see SC1.C) */
 #define tENDLESS 342 /* endless loop, for assigment to "lastst" only */
+#define tEMPTYBLOCK 343 /* empty blocks for AM bug 4825 */
 
 /* (reversed) evaluation of staging buffer */
 #define sSTARTREORDER 0x01
diff --git a/sourcepawn/compiler/sc1.c b/sourcepawn/compiler/sc1.c
index 49e258db..9685333c 100644
--- a/sourcepawn/compiler/sc1.c
+++ b/sourcepawn/compiler/sc1.c
@@ -5660,9 +5660,13 @@ static void statement(int *lastindent,int allow_decl)
   case '{':
   case tBEGIN:
     save=fline;
-    if (!matchtoken('}'))       /* {} is the empty statement */
+    if (!matchtoken('}')) {       /* {} is the empty statement */
       compound(save==fline,tok);
-    /* lastst (for "last statement") does not change */
+    } else {
+      lastst = tEMPTYBLOCK;
+	}
+    /* lastst (for "last statement") does not change 
+       you're not my father, don't tell me what to do */
     break;
   case ';':
     error(36);                  /* empty statement */
@@ -5990,6 +5994,12 @@ static int doif(void)
     setlabel(flab1);            /* print false label */
     statement(NULL,FALSE);      /* do "else" clause */
     setlabel(flab2);            /* print true label */
+    /* if both the "true" branch and the "false" branch ended with the same
+     * kind of statement, set the last statement id to that kind, rather than
+     * to the generic tIF; this allows for better "unreachable code" checking
+     */
+    if (lastst==lastst_true)
+      return lastst;
   } /* if */
   return tIF;
 }