public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
* [jit] Add typechecking to binary ops and comparisons
@ 2014-01-01  0:00 David Malcolm
  0 siblings, 0 replies; only message in thread
From: David Malcolm @ 2014-01-01  0:00 UTC (permalink / raw)
  To: jit, gcc-patches; +Cc: David Malcolm

Committed to branch dmalcolm/jit:

gcc/jit/
	* libgccjit.c (gcc_jit_context_new_binary_op): Check that the
	operands have the same type.
	(gcc_jit_context_new_comparison): Likewise.
---
 gcc/jit/ChangeLog.jit |  6 ++++++
 gcc/jit/libgccjit.c   | 18 ++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/gcc/jit/ChangeLog.jit b/gcc/jit/ChangeLog.jit
index 625e01a..f2fea8c 100644
--- a/gcc/jit/ChangeLog.jit
+++ b/gcc/jit/ChangeLog.jit
@@ -1,5 +1,11 @@
 2014-02-28  David Malcolm  <dmalcolm@redhat.com>
 
+	* libgccjit.c (gcc_jit_context_new_binary_op): Check that the
+	operands have the same type.
+	(gcc_jit_context_new_comparison): Likewise.
+
+2014-02-28  David Malcolm  <dmalcolm@redhat.com>
+
 	* libgccjit.h (gcc_jit_context_new_cast): New.
 	* libgccjit.map (gcc_jit_context_new_cast): New.
 	* libgccjit++.h (gccjit::context::new_cast): New method.
diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c
index 6c078ce..d9f63cf 100644
--- a/gcc/jit/libgccjit.c
+++ b/gcc/jit/libgccjit.c
@@ -752,6 +752,15 @@ gcc_jit_context_new_binary_op (gcc_jit_context *ctxt,
   RETURN_NULL_IF_FAIL (result_type, ctxt, "NULL result_type");
   RETURN_NULL_IF_FAIL (a, ctxt, "NULL a");
   RETURN_NULL_IF_FAIL (b, ctxt, "NULL b");
+  RETURN_NULL_IF_FAIL_PRINTF4 (
+    a->get_type () == b->get_type (),
+    ctxt,
+    "mismatching types for binary op:"
+    " a: %s (type: %s) b: %s (type: %s)",
+    a->get_debug_string (),
+    a->get_type ()->get_debug_string (),
+    b->get_debug_string (),
+    b->get_type ()->get_debug_string ());
 
   return (gcc_jit_rvalue *)ctxt->new_binary_op (loc, op, result_type, a, b);
 }
@@ -766,6 +775,15 @@ gcc_jit_context_new_comparison (gcc_jit_context *ctxt,
   /* op is checked by the inner function.  */
   RETURN_NULL_IF_FAIL (a, ctxt, "NULL a");
   RETURN_NULL_IF_FAIL (b, ctxt, "NULL b");
+  RETURN_NULL_IF_FAIL_PRINTF4 (
+    a->get_type () == b->get_type (),
+    ctxt,
+    "mismatching types for comparison:"
+    " a: %s (type: %s) b: %s (type: %s)",
+    a->get_debug_string (),
+    a->get_type ()->get_debug_string (),
+    b->get_debug_string (),
+    b->get_type ()->get_debug_string ());
 
   return (gcc_jit_rvalue *)ctxt->new_comparison (loc, op, a, b);
 }
-- 
1.7.11.7

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-02-28 23:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-01  0:00 [jit] Add typechecking to binary ops and comparisons David Malcolm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).