]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - parser.c
propagate the 'inexact' flag on when initializing a constant
[xonotic/gmqcc.git] / parser.c
index 00f8dfd7c4db44706ce731f8cff3eb4417da0312..5666a828a565886b72068d6152eeb07a577730af 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -5842,7 +5842,6 @@ skipvar:
                     else
                     {
                         var->hasvalue = true;
-                        var->inexact  = ((ast_value*)cexp)->inexact;
                         if (cval->expression.vtype == TYPE_STRING)
                             var->constval.vstring = parser_strdup(cval->constval.vstring);
                         else if (cval->expression.vtype == TYPE_FIELD)
@@ -5873,6 +5872,14 @@ skipvar:
                 vec_free(sy.argc);
                 var->cvq = cvq;
             }
+            /* a constant initialized to an inexact value should be marked inexact:
+             * const float x = <inexact>; should propagate the inexact flag
+             */
+            if (var->cvq == CV_CONST && var->expression.vtype == TYPE_FLOAT) {
+                cval = (ast_value*)cexp;
+                if (ast_istype(cexp, ast_value) && cval->hasvalue && cval->cvq == CV_CONST)
+                    var->inexact = cval->inexact;
+            }
         }
 
 another: