From: Wolfgang Bumiller Date: Sat, 24 May 2014 15:51:26 +0000 (+0200) Subject: propagate the 'inexact' flag on when initializing a constant X-Git-Tag: xonotic-v0.8.1~9^2~32^2~10 X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=commitdiff_plain;h=536138273f7d9d82fe9212dfa06873a95d548c1d propagate the 'inexact' flag on when initializing a constant --- diff --git a/parser.c b/parser.c index 00f8dfd..5666a82 100644 --- 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 = ; 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: