glsl2: Validate that ir_if conditions are actually bool.
authorEric Anholt <eric@anholt.net>
Thu, 22 Jul 2010 23:24:49 +0000 (16:24 -0700)
committerEric Anholt <eric@anholt.net>
Thu, 22 Jul 2010 23:24:49 +0000 (16:24 -0700)
src/glsl/ir_validate.cpp

index c05edf2ee3d1ae052224bdf4aa7f5abb3d7337c2..bb381a00df3480a1dc5bd583d2f356feba69b149 100644 (file)
@@ -59,6 +59,7 @@ public:
 
    virtual ir_visitor_status visit(ir_variable *v);
    virtual ir_visitor_status visit(ir_dereference_variable *ir);
+   virtual ir_visitor_status visit(ir_if *ir);
 
    virtual ir_visitor_status visit_enter(ir_function *ir);
    virtual ir_visitor_status visit_leave(ir_function *ir);
@@ -93,6 +94,18 @@ ir_validate::visit(ir_dereference_variable *ir)
    return visit_continue;
 }
 
+ir_visitor_status
+ir_validate::visit(ir_if *ir)
+{
+   if (ir->condition->type != glsl_type::bool_type) {
+      printf("ir_if condition %s type instead of bool.\n",
+            ir->condition->type->name);
+      ir->print();
+      printf("\n");
+      abort();
+   }
+}
+
 
 ir_visitor_status
 ir_validate::visit_enter(ir_function *ir)