diff options
author | Eric Anholt <eric@anholt.net> | 2010-03-31 15:53:26 -1000 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2010-04-02 11:05:16 -0700 |
commit | 307c71bf24a3c99409ccf4b8b10f161e4b032cba (patch) | |
tree | 3a77ea0a156a6c55b8985fb01bc47863ae8b789f | |
parent | ac3af37d27c49704dd3b2d303b4497b08f8b47fd (diff) |
Compute the constant value of a constant initializer.
Fixes constFunc.frag.
-rw-r--r-- | ast_to_hir.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 11000a8134..aa7e165ee7 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1434,13 +1434,22 @@ ast_declarator_list::hir(exec_list *instructions, } ir_dereference *const lhs = new ir_dereference(var); - ir_rvalue *const rhs = decl->initializer->hir(instructions, state); + ir_rvalue *rhs = decl->initializer->hir(instructions, state); - /* FINISHME: If the declaration is either 'const' or 'uniform', the - * FINISHME: initializer (rhs) must be a constant expression. + /* Calculate the constant value if this is a const + * declaration. */ + if (this->type->qualifier.constant) { + rhs = rhs->constant_expression_value(); + if (!rhs) { + _mesa_glsl_error(& initializer_loc, state, + "initializer of const variable `%s' must be a " + "constant expression", + decl->identifier); + } + } - if (!rhs->type->is_error()) { + if (rhs && !rhs->type->is_error()) { bool temp = var->read_only; if (this->type->qualifier.constant) var->read_only = false; |