jit: prevent ICE with type mismatch in gcc_jit_block_add_assignment_op
authorDavid Malcolm <dmalcolm@redhat.com>
Thu, 15 Jan 2015 19:36:42 +0000 (19:36 +0000)
committerDavid Malcolm <dmalcolm@gcc.gnu.org>
Thu, 15 Jan 2015 19:36:42 +0000 (19:36 +0000)
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
gcc/jit/libgccjit.c
gcc/testsuite/ChangeLog

index d15a21424b2d6fd99ac2ac9f9b56208d53fa8d8c..70a3d5707ff275b1cf01495ff2b03c930658e7dc 100644 (file)
@@ -1,3 +1,8 @@
+2015-01-15  David Malcolm  <dmalcolm@redhat.com>
+
+       * libgccjit.c (gcc_jit_block_add_assignment_op): Check that the
+       lvalue and the rvalue are of compatible type.
+
 2015-01-13  David Malcolm  <dmalcolm@redhat.com>
 
        * docs/cp/topics/contexts.rst (Debugging): Add
index a78b3e7514cd9a922e52c04c52d69776ae1cc7a8..0faf0f9529dc71ff45afb67b9ba6052e02cb9886 100644 (file)
@@ -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);
 
index f6b2ae3ab4d6fae34b9d7b1eedc65f0687f34c21..d9525d59650a2dbf400f3f412a87dc8d850d6c3b 100644 (file)
@@ -1,3 +1,8 @@
+2015-01-15  David Malcolm  <dmalcolm@redhat.com>
+
+       * jit.dg/test-error-mismatching-types-in-assignment-op.c: New
+       test case.
+
 2015-01-15  Mike Stump  <mikestump@comcast.net>
 
        * gcc.dg/inline_1.c: Rename gcc.dg/inline_[1-4].c to inline-3[6-9].c.