diff options
author | Eric Anholt <eric@anholt.net> | 2010-03-31 09:29:33 -1000 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2010-03-31 13:17:23 -0700 |
commit | 0ed61257253fc0df1dde9042cb0e7fe22d58077a (patch) | |
tree | e381f61a1fdf8f20880b2ea4dd45e60119cda46d | |
parent | e0800062daf237a9e4f893bc3db473da8f7472c0 (diff) |
Test that const declarations include initializers.
Fixes dataType6.frag, and also array2.frag for an unexpected but valid
reason.
-rw-r--r-- | ast_to_hir.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 375955d033..c9aa91e7f0 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1329,6 +1329,17 @@ ast_declarator_list::hir(exec_list *instructions, } } + /* From page 23 (page 29 of the PDF) of the GLSL 1.10 spec: + * + * "It is an error to write to a const variable outside of + * its declaration, so they must be initialized when + * declared." + */ + if (this->type->qualifier.constant && decl->initializer == NULL) { + _mesa_glsl_error(& loc, state, + "const declaration of `%s' must be initialized"); + } + /* Add the vairable to the symbol table after processing the initializer. * This differs from most C-like languages, but it follows the GLSL * specification. From page 28 (page 34 of the PDF) of the GLSL 1.50 |