[Mesa-dev] [PATCH] glsl: fix compiling warning from gcc 4.7

Brian Paul brianp at vmware.com
Wed Mar 14 07:30:21 PDT 2012


On 03/13/2012 10:05 AM, Dave Airlie wrote:
> From: Dave Airlie<airlied at redhat.com>
>
> ir_validate.cpp: In member function ‘virtual ir_visitor_status ir_validate::visit_leave(ir_swizzle*)’:
> ir_validate.cpp:458:66: warning: narrowing conversion of ‘ir->ir_swizzle::mask.ir_swizzle_mask::x’ from ‘unsigned int’ to ‘int’ inside { } is ill-formed in C++11 [-Wnarrowing]
> ir_validate.cpp:458:66: warning: narrowing conversion of ‘ir->ir_swizzle::mask.ir_swizzle_mask::y’ from ‘unsigned int’ to ‘int’ inside { } is ill-formed in C++11 [-Wnarrowing]
> ir_validate.cpp:458:66: warning: narrowing conversion of ‘ir->ir_swizzle::mask.ir_swizzle_mask::z’ from ‘unsigned int’ to ‘int’ inside { } is ill-formed in C++11 [-Wnarrowing]
> ir_validate.cpp:458:66: warning: narrowing conversion of ‘ir->ir_swizzle::mask.ir_swizzle_mask::w’ from ‘unsigned int’ to ‘int’ inside { } is ill-formed in C++11 [-Wnarrowing]
>
> Signed-off-by: Dave Airlie<airlied at redhat.com>
> ---
>   src/glsl/ir_validate.cpp |    2 +-
>   1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp
> index 20a0377..101d999 100644
> --- a/src/glsl/ir_validate.cpp
> +++ b/src/glsl/ir_validate.cpp
> @@ -455,7 +455,7 @@ ir_validate::visit_leave(ir_expression *ir)
>   ir_visitor_status
>   ir_validate::visit_leave(ir_swizzle *ir)
>   {
> -   int chans[4] = {ir->mask.x, ir->mask.y, ir->mask.z, ir->mask.w};
> +   unsigned int chans[4] = {ir->mask.x, ir->mask.y, ir->mask.z, ir->mask.w};
>
>      for (unsigned int i = 0; i<  ir->type->vector_elements; i++) {
>         if (chans[i]>= ir->val->type->vector_elements) {

Looks OK to me.

Reviewed-by: Brian Paul <brianp at vmware.com>


More information about the mesa-dev mailing list