Apply implicit conversions to ?: operator
authorIan Romanick <ian.d.romanick@intel.com>
Mon, 29 Mar 2010 23:25:56 +0000 (16:25 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Mon, 29 Mar 2010 23:29:26 +0000 (16:29 -0700)
ast_to_hir.cpp

index 3450d38..dfb2e40 100644 (file)
@@ -794,18 +794,18 @@ ast_expression::hir(exec_list *instructions,
        *     resulting matching type is the type of the entire
        *     expression."
        */
-      /* FINISHME: Apply implicit conversions */
-      if (op[1]->type == op[2]->type) {
-        tmp->type = op[1]->type;
-      } else {
+      if ((!apply_implicit_conversion(op[1]->type, & op[2], state)
+          && !apply_implicit_conversion(op[2]->type, & op[1], state))
+         || (op[1]->type != op[2]->type)) {
         YYLTYPE loc = this->subexpressions[1]->get_location();
 
         _mesa_glsl_error(& loc, state, "Second and third operands of ?: "
                          "operator must have matching types.");
         error_emitted = true;
+      } else {
+        tmp->type = op[1]->type;
       }
 
-
       result = new ir_dereference(tmp);
       type = tmp->type;
       break;