]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
fixed: -frelaxed-switch check was in the wrong position
authorWolfgang (Blub) Bumiller <blub@speed.at>
Sun, 25 Nov 2012 18:42:16 +0000 (19:42 +0100)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Sun, 25 Nov 2012 18:42:16 +0000 (19:42 +0100)
parser.c

index 3883631092b247ab995bc737d65cae1b58aff184..370f92fab6ec39b34e9412fd4df87de7ab1baf8d 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -2107,15 +2107,6 @@ static bool parse_switch(parser_t *parser, ast_block *block, ast_expression **ou
     if (!operand)
         return false;
 
-    if (!OPTS_FLAG(RELAXED_SWITCH)) {
-        opval = (ast_value*)operand;
-        if (!ast_istype(operand, ast_value) || !opval->constant) {
-            parseerror(parser, "case on non-constant values need to be explicitly enabled via -frelaxed-switch");
-            ast_unref(operand);
-            return false;
-        }
-    }
-
     switchnode = ast_switch_new(ctx, operand);
 
     /* closing paren */
@@ -2159,6 +2150,14 @@ static bool parse_switch(parser_t *parser, ast_block *block, ast_expression **ou
                 parseerror(parser, "expected expression for case");
                 return false;
             }
+            if (!OPTS_FLAG(RELAXED_SWITCH)) {
+                opval = (ast_value*)swcase.value;
+                if (!ast_istype(swcase.value, ast_value) || !opval->constant) {
+                    parseerror(parser, "case on non-constant values need to be explicitly enabled via -frelaxed-switch");
+                    ast_unref(operand);
+                    return false;
+                }
+            }
         }
         else if (!strcmp(parser_tokval(parser), "default")) {
             swcase.value = NULL;