]> de.git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - parser.c
more on CV_CONST/CV_VAR, initializers to check 'constant' not just 'hasvalue'
[xonotic/gmqcc.git] / parser.c
index 2b944ca9d21fe82651eb09ef4d96d728752af372..6e440cd4c1c638a73173f0309219694c84a989d1 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -3505,7 +3505,7 @@ static bool parse_variable(parser_t *parser, ast_block *localblock, bool nofield
             }
         }
 
-        if (is_const_var > 0)
+        if (is_const_var == CV_CONST)
             var->constant = true;
 
         /* Part 1:
@@ -3856,12 +3856,12 @@ skipvar:
 
             if (!localblock) {
                 cval = (ast_value*)cexp;
-                if (!ast_istype(cval, ast_value) || !cval->hasvalue)
+                if (!ast_istype(cval, ast_value) || !cval->hasvalue || !cval->constant)
                     parseerror(parser, "cannot initialize a global constant variable with a non-constant expression");
                 else
                 {
                     if (opts_standard != COMPILER_GMQCC && !OPTS_FLAG(INITIALIZED_NONCONSTANTS) &&
-                        is_const_var >= 0)
+                        is_const_var != CV_VAR)
                     {
                         var->constant = true;
                     }