glsl: silence uninitialized var warning in read_texture()
authorBrian Paul <brianp@vmware.com>
Tue, 25 Jan 2011 20:09:57 +0000 (13:09 -0700)
committerBrian Paul <brianp@vmware.com>
Tue, 25 Jan 2011 20:11:47 +0000 (13:11 -0700)
And generate an error if the texture pattern is not matched.

src/glsl/ir_reader.cpp

index 0a2f74304d1e7aa161908dfb2587503deda47d58..b78aa051b450cd0f7ca11c722d928a8fae7d6169 100644 (file)
@@ -876,7 +876,7 @@ ir_reader::read_texture(s_expression *expr)
    s_list *s_shadow = NULL;
    s_expression *s_lod = NULL;
 
-   ir_texture_opcode op;
+   ir_texture_opcode op = ir_tex; /* silence warning */
 
    s_pattern tex_pattern[] =
       { "tex", s_sampler, s_coord, s_offset, s_proj, s_shadow };
@@ -893,6 +893,9 @@ ir_reader::read_texture(s_expression *expr)
       op = ir_texture::get_opcode(tag->value());
       if (op == -1)
         return NULL;
+   } else {
+      ir_read_error(NULL, "unexpected texture pattern");
+      return NULL;
    }
 
    ir_texture *tex = new(mem_ctx) ir_texture(op);