[Mesa-dev] [PATCH 2/2] glsl: do not raise uninitialized warning with in/inout function parameters
Ian Romanick
idr at freedesktop.org
Tue Apr 26 11:55:02 UTC 2016
On 04/19/2016 07:48 PM, Alejandro PiƱeiro wrote:
> 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/inout modes
> checks are done.
> ---
> src/compiler/glsl/ast_function.cpp | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> diff --git a/src/compiler/glsl/ast_function.cpp b/src/compiler/glsl/ast_function.cpp
> index db68d5d..3b60a9c 100644
> --- a/src/compiler/glsl/ast_function.cpp
> +++ b/src/compiler/glsl/ast_function.cpp
> @@ -43,6 +43,11 @@ 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. */
The */ goes on its own line for multi-line comments.
> + ast->set_is_lhs(true);
> ir_rvalue *result = ast->hir(instructions, state);
>
> ir_constant *const constant = result->constant_expression_value();
> @@ -263,6 +268,19 @@ 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);
There's a lot of code in the compiler that is formatted like this, but I
think the will of the group is to put || and && on the end of the
preceding line.
> + ir_variable *var = actual->variable_referenced();
> + if (var != NULL) {
> + if ((var->data.mode == ir_var_auto || var->data.mode == ir_var_shader_out)
> + && var->data.assigned != true
&& !var->data.assigned
> + && !is_gl_identifier(var->name)) {
> + _mesa_glsl_warning(&loc, state, "`%s' used uninitialized",
> + var->name);
> + }
> + }
> +
Extra blank line here.
> }
>
> if (formal->type->is_image() &&
>
More information about the mesa-dev
mailing list