summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorAlejandro Piñeiro <[email protected]>2016-02-23 11:48:52 +0100
committerAlejandro Piñeiro <[email protected]>2016-03-29 07:28:57 +0200
commitdcd41ca87a06199184eb8ada654aec985185189c (patch)
tree52f5d1fdc906c8220235103a6b6504cc42711251 /src/compiler
parent8568d02498d12ebde6a6245056eebfbfe18aaf8f (diff)
glsl: raise warning when using uninitialized variables
v2: * Take into account out varyings too (Timothy Arceri) * Fix style (Timothy Arceri) * Use a new ast_expression variable, instead of an ast_expression::hir new parameter (Timothy Arceri) Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=94129 Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/glsl/ast_to_hir.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index e162203c1c8..29a4642af2c 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -1901,6 +1901,13 @@ ast_expression::do_hir(exec_list *instructions,
if (var != NULL) {
var->data.used = true;
result = new(ctx) ir_dereference_variable(var);
+
+ if ((var->data.mode == ir_var_auto || var->data.mode == ir_var_shader_out)
+ && !this->is_lhs
+ && result->variable_referenced()->data.assigned != true) {
+ _mesa_glsl_warning(&loc, state, "`%s' used uninitialized",
+ this->primary_expression.identifier);
+ }
} else {
_mesa_glsl_error(& loc, state, "`%s' undeclared",
this->primary_expression.identifier);