From 96a87981994da859c17259d8c4dccb6602476b0e Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Thu, 15 Jan 2015 19:36:42 +0000 Subject: [PATCH] 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 --- gcc/jit/ChangeLog | 5 +++++ gcc/jit/libgccjit.c | 10 ++++++++++ gcc/testsuite/ChangeLog | 5 +++++ 3 files changed, 20 insertions(+) diff --git a/gcc/jit/ChangeLog b/gcc/jit/ChangeLog index d15a21424b2..70a3d5707ff 100644 --- a/gcc/jit/ChangeLog +++ b/gcc/jit/ChangeLog @@ -1,3 +1,8 @@ +2015-01-15 David Malcolm + + * libgccjit.c (gcc_jit_block_add_assignment_op): Check that the + lvalue and the rvalue are of compatible type. + 2015-01-13 David Malcolm * docs/cp/topics/contexts.rst (Debugging): Add diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c index a78b3e7514c..0faf0f9529d 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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f6b2ae3ab4d..d9525d59650 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-01-15 David Malcolm + + * jit.dg/test-error-mismatching-types-in-assignment-op.c: New + test case. + 2015-01-15 Mike Stump * gcc.dg/inline_1.c: Rename gcc.dg/inline_[1-4].c to inline-3[6-9].c. -- 2.30.2