summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/ast_to_hir.cpp
diff options
context:
space:
mode:
authorIlia Mirkin <imirkin@alum.mit.edu>2016-07-08 23:28:22 -0400
committerIlia Mirkin <imirkin@alum.mit.edu>2016-08-12 22:45:20 -0400
commita32c87f74be1beed546d6d8853933d1b48f42f18 (patch)
tree7b80e8f56f223850fcf5f12dfba788eb2fc84c27 /src/compiler/glsl/ast_to_hir.cpp
parentd816a51b81f42b0aa4819a32587b4aa167e4b541 (diff)
downloadexternal_mesa3d-a32c87f74be1beed546d6d8853933d1b48f42f18.zip
external_mesa3d-a32c87f74be1beed546d6d8853933d1b48f42f18.tar.gz
external_mesa3d-a32c87f74be1beed546d6d8853933d1b48f42f18.tar.bz2
glsl: emit a specific error when ast_*_assign changes type
For regular ast_add, we can implicitly change either a or b's type. However in an assignment situation, the type of the lvalue is fixed. So if the implicit conversion logic decides to change it, it means that the rhs's type could not be converted to the lhs type. Emit a specific error for this rather than the rather mysterious "is not an lvalue" error that results from having a i2f or other operation as the lvalue. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96729 Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu> Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
Diffstat (limited to 'src/compiler/glsl/ast_to_hir.cpp')
-rw-r--r--src/compiler/glsl/ast_to_hir.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
index f189075..e03a6e3 100644
--- a/src/compiler/glsl/ast_to_hir.cpp
+++ b/src/compiler/glsl/ast_to_hir.cpp
@@ -1355,7 +1355,7 @@ ast_expression::do_hir(exec_list *instructions,
};
ir_rvalue *result = NULL;
ir_rvalue *op[3];
- const struct glsl_type *type; /* a temporary variable for switch cases */
+ const struct glsl_type *type, *orig_type;
bool error_emitted = false;
YYLTYPE loc;
@@ -1645,10 +1645,18 @@ ast_expression::do_hir(exec_list *instructions,
op[0] = this->subexpressions[0]->hir(instructions, state);
op[1] = this->subexpressions[1]->hir(instructions, state);
+ orig_type = op[0]->type;
type = arithmetic_result_type(op[0], op[1],
(this->oper == ast_mul_assign),
state, & loc);
+ if (type != orig_type) {
+ _mesa_glsl_error(& loc, state,
+ "could not implicitly convert "
+ "%s to %s", type->name, orig_type->name);
+ type = glsl_type::error_type;
+ }
+
ir_rvalue *temp_rhs = new(ctx) ir_expression(operations[this->oper], type,
op[0], op[1]);
@@ -1672,8 +1680,16 @@ ast_expression::do_hir(exec_list *instructions,
op[0] = this->subexpressions[0]->hir(instructions, state);
op[1] = this->subexpressions[1]->hir(instructions, state);
+ orig_type = op[0]->type;
type = modulus_result_type(op[0], op[1], state, &loc);
+ if (type != orig_type) {
+ _mesa_glsl_error(& loc, state,
+ "could not implicitly convert "
+ "%s to %s", type->name, orig_type->name);
+ type = glsl_type::error_type;
+ }
+
assert(operations[this->oper] == ir_binop_mod);
ir_rvalue *temp_rhs;
@@ -1713,7 +1729,17 @@ ast_expression::do_hir(exec_list *instructions,
this->subexpressions[0]->set_is_lhs(true);
op[0] = this->subexpressions[0]->hir(instructions, state);
op[1] = this->subexpressions[1]->hir(instructions, state);
+
+ orig_type = op[0]->type;
type = bit_logic_result_type(op[0], op[1], this->oper, state, &loc);
+
+ if (type != orig_type) {
+ _mesa_glsl_error(& loc, state,
+ "could not implicitly convert "
+ "%s to %s", type->name, orig_type->name);
+ type = glsl_type::error_type;
+ }
+
ir_rvalue *temp_rhs = new(ctx) ir_expression(operations[this->oper],
type, op[0], op[1]);
error_emitted =