diff --git a/tools/qfcc/include/symtab.h b/tools/qfcc/include/symtab.h index 5a3108fa9..fcebcd45c 100644 --- a/tools/qfcc/include/symtab.h +++ b/tools/qfcc/include/symtab.h @@ -69,6 +69,7 @@ typedef struct symbol_s { struct param_s *params; ///< the parameters if a function bool no_auto_init:1; ///< skip for non-designated initializers bool lvalue:1; + bool is_constexpr:1; struct attribute_s *attributes; union { int offset; ///< sy_offset diff --git a/tools/qfcc/source/expr.c b/tools/qfcc/source/expr.c index 03cdc6087..d2d1eef2e 100644 --- a/tools/qfcc/source/expr.c +++ b/tools/qfcc/source/expr.c @@ -74,7 +74,7 @@ convert_name (const expr_t *e) { symbol_t *sym; - if (!e || e->type != ex_symbol) + if (!e || e->type != ex_symbol || e->symbol->is_constexpr) return e; sym = e->symbol; @@ -993,6 +993,9 @@ is_constexpr (const expr_t *e) if ((e->type == ex_expr || e->type == ex_uexpr) && e->expr.constant) { return true; } + if (e->type == ex_symbol) { + return e->symbol->is_constexpr; + } return is_constant (e); } diff --git a/tools/qfcc/source/glsl-layout.c b/tools/qfcc/source/glsl-layout.c index 2f94492e6..01f366005 100644 --- a/tools/qfcc/source/glsl-layout.c +++ b/tools/qfcc/source/glsl-layout.c @@ -83,12 +83,7 @@ glsl_layout_constant_id (specifier_t spec, const expr_t *qual_name, spec.sym->sy_type = sy_expr; spec.sym->expr = expr; } - if (spec.sym->sy_type == sy_expr && spec.sym->expr->type == ex_value) { - auto expr = new_unary_expr ('+', spec.sym->expr); - expr->expr.constant = true; - expr->expr.type = spec.sym->type; - spec.sym->expr = expr; - } + spec.sym->is_constexpr = true; const char *name = expr_string (qual_name); set_attribute (&spec.sym->attributes, name, val); }