mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-04-07 01:42:04 +00:00
[qfcc] Preserve symbol expressions when constexpr
This prevents them from getting folded out of existence and thus impossible to specialize.
This commit is contained in:
parent
491b612888
commit
3af078628e
3 changed files with 6 additions and 7 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue