summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlejandro Piñeiro <[email protected]>2016-04-19 11:17:27 +0200
committerAlejandro Piñeiro <[email protected]>2016-05-26 08:39:17 +0200
commit66ff04322e80d14d9b1c8a4d1ef8cf63440242af (patch)
tree394c200bcb82a83b5745671f6cb39b3984eee290 /src
parentb9f90ef652dae687a5aff97f9132b374320638a5 (diff)
glsl: do not raise uninitialized warning with out function parameters
It silence by default warnings with function parameters, as the parameters need to be processed in order to have the actual and the formal parameter, and the function signature. Then it raises the warning if needed at verify_parameter_modes where other in/out/inout modes checks are done. v2: fix comment style, multi-line condition style, simplify check, remove extra blank (Ian Romanick) v3: inout function parameters can raise the warning too (Ian Romanick) Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/compiler/glsl/ast_function.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/compiler/glsl/ast_function.cpp b/src/compiler/glsl/ast_function.cpp
index 4433fdd4875..a97e6c96114 100644
--- a/src/compiler/glsl/ast_function.cpp
+++ b/src/compiler/glsl/ast_function.cpp
@@ -43,6 +43,12 @@ process_parameters(exec_list *instructions, exec_list *actual_parameters,
unsigned count = 0;
foreach_list_typed(ast_node, ast, link, parameters) {
+ /* We need to process the parameters first in order to know if we can
+ * raise or not a unitialized warning. Calling set_is_lhs silence the
+ * warning for now. Raising the warning or not will be checked at
+ * verify_parameter_modes.
+ */
+ ast->set_is_lhs(true);
ir_rvalue *result = ast->hir(instructions, state);
ir_constant *const constant = result->constant_expression_value();
@@ -257,6 +263,16 @@ verify_parameter_modes(_mesa_glsl_parse_state *state,
}
ir_variable *var = actual->variable_referenced();
+
+ if (var && formal->data.mode == ir_var_function_inout) {
+ if ((var->data.mode == ir_var_auto || var->data.mode == ir_var_shader_out) &&
+ !var->data.assigned &&
+ !is_gl_identifier(var->name)) {
+ _mesa_glsl_warning(&loc, state, "`%s' used uninitialized",
+ var->name);
+ }
+ }
+
if (var)
var->data.assigned = true;
@@ -273,6 +289,18 @@ verify_parameter_modes(_mesa_glsl_parse_state *state,
mode, formal->name);
return false;
}
+ } else {
+ assert(formal->data.mode == ir_var_function_in ||
+ formal->data.mode == ir_var_const_in);
+ ir_variable *var = actual->variable_referenced();
+ if (var) {
+ if ((var->data.mode == ir_var_auto || var->data.mode == ir_var_shader_out) &&
+ !var->data.assigned &&
+ !is_gl_identifier(var->name)) {
+ _mesa_glsl_warning(&loc, state, "`%s' used uninitialized",
+ var->name);
+ }
+ }
}
if (formal->type->is_image() &&