static const struct glsl_type *
arithmetic_result_type(ir_rvalue * &value_a, ir_rvalue * &value_b,
bool multiply,
- struct _mesa_glsl_parse_state *state)
+ struct _mesa_glsl_parse_state *state, YYLTYPE *loc)
{
const glsl_type *const type_a = value_a->type;
const glsl_type *const type_b = value_b->type;
* floating-point scalars, vectors, and matrices."
*/
if (!type_a->is_numeric() || !type_b->is_numeric()) {
+ _mesa_glsl_error(loc, state,
+ "Operands to arithmetic operators must be numeric");
return glsl_type::error_type;
}
*/
if (!apply_implicit_conversion(type_a, value_b, state)
&& !apply_implicit_conversion(type_b, value_a, state)) {
+ _mesa_glsl_error(loc, state,
+ "Could not implicitly convert operands to "
+ "arithmetic operator");
return glsl_type::error_type;
}
* equality.
*/
if (type_a->base_type != type_b->base_type) {
+ _mesa_glsl_error(loc, state,
+ "base type mismatch for arithmetic operator");
return glsl_type::error_type;
}
* vector."
*/
if (type_a->is_vector() && type_b->is_vector()) {
- return (type_a == type_b) ? type_a : glsl_type::error_type;
+ if (type_a == type_b) {
+ return type_a;
+ } else {
+ _mesa_glsl_error(loc, state,
+ "vector size mismatch for arithmetic operator");
+ return glsl_type::error_type;
+ }
}
/* All of the combinations of <scalar, scalar>, <vector, scalar>,
* more detail how vectors and matrices are operated on."
*/
if (! multiply) {
- return (type_a == type_b) ? type_a : glsl_type::error_type;
+ if (type_a == type_b)
+ return type_a;
} else {
if (type_a->is_matrix() && type_b->is_matrix()) {
/* Matrix multiply. The columns of A must match the rows of B. Given
* looking at the size of a vector that makes up a column. The
* transpose (size of a row) is done for B.
*/
- return
+ const glsl_type *const type =
glsl_type::get_instance(type_a->base_type,
type_a->column_type()->vector_elements,
type_b->row_type()->vector_elements);
+ assert(type != glsl_type::error_type);
+
+ return type;
}
} else if (type_a->is_matrix()) {
/* A is a matrix and B is a column vector. Columns of A must match
if (type_a == type_b->column_type())
return type_a;
}
+
+ _mesa_glsl_error(loc, state, "size mismatch for matrix multiplication");
+ return glsl_type::error_type;
}
/* "All other cases are illegal."
*/
+ _mesa_glsl_error(loc, state, "type mismatch");
return glsl_type::error_type;
}
type = arithmetic_result_type(op[0], op[1],
(this->oper == ast_mul),
- state);
+ state, & loc);
+ error_emitted = type->is_error();
result = new ir_expression(operations[this->oper], type,
op[0], op[1]);
type = arithmetic_result_type(op[0], op[1],
(this->oper == ast_mul_assign),
- state);
+ state, & loc);
ir_rvalue *temp_rhs = new ir_expression(operations[this->oper], type,
op[0], op[1]);
else
op[1] = new ir_constant(1);
- type = arithmetic_result_type(op[0], op[1], false, state);
+ type = arithmetic_result_type(op[0], op[1], false, state, & loc);
struct ir_rvalue *temp_rhs;
temp_rhs = new ir_expression(operations[this->oper], type,
error_emitted = op[0]->type->is_error() || op[1]->type->is_error();
- type = arithmetic_result_type(op[0], op[1], false, state);
+ type = arithmetic_result_type(op[0], op[1], false, state, & loc);
struct ir_rvalue *temp_rhs;
temp_rhs = new ir_expression(operations[this->oper], type,