aboutsummaryrefslogtreecommitdiff
path: root/gcc/jit/libgccjit.c
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2015-01-15 19:36:42 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2015-01-15 19:36:42 +0000
commit96a87981994da859c17259d8c4dccb6602476b0e (patch)
tree91f8600207abbecbd0638e2f11fe8eda9705d731 /gcc/jit/libgccjit.c
parent548c43e724cc6dc360afe75816396c7d5eba38fc (diff)
downloadgcc-96a87981994da859c17259d8c4dccb6602476b0e.zip
gcc-96a87981994da859c17259d8c4dccb6602476b0e.tar.gz
gcc-96a87981994da859c17259d8c4dccb6602476b0e.tar.bz2
jit: prevent ICE with type mismatch in gcc_jit_block_add_assignment_op
gcc/jit/ChangeLog: * libgccjit.c (gcc_jit_block_add_assignment_op): Check that the lvalue and the rvalue are of compatible type. gcc/testsuite/ChangeLog: * jit.dg/test-error-mismatching-types-in-assignment-op.c: New test case. From-SVN: r219681
Diffstat (limited to 'gcc/jit/libgccjit.c')
-rw-r--r--gcc/jit/libgccjit.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c
index a78b3e7..0faf0f9 100644
--- a/gcc/jit/libgccjit.c
+++ b/gcc/jit/libgccjit.c
@@ -1900,6 +1900,16 @@ gcc_jit_block_add_assignment_op (gcc_jit_block *block,
"unrecognized value for enum gcc_jit_binary_op: %i",
op);
RETURN_IF_FAIL (rvalue, ctxt, loc, "NULL rvalue");
+ RETURN_IF_FAIL_PRINTF4 (
+ compatible_types (lvalue->get_type (),
+ rvalue->get_type ()),
+ ctxt, loc,
+ "mismatching types:"
+ " assignment to %s (type: %s) involving %s (type: %s)",
+ lvalue->get_debug_string (),
+ lvalue->get_type ()->get_debug_string (),
+ rvalue->get_debug_string (),
+ rvalue->get_type ()->get_debug_string ());
gcc::jit::recording::statement *stmt = block->add_assignment_op (loc, lvalue, op, rvalue);