From 536138273f7d9d82fe9212dfa06873a95d548c1d Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Sat, 24 May 2014 17:51:26 +0200 Subject: [PATCH] propagate the 'inexact' flag on when initializing a constant --- parser.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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: -- 2.39.2