public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][gcc] libgccjit: check result_type in gcc_jit_context_new_binary_op
@ 2019-01-01  0:00 Andrea Corallo
  2019-01-01  0:00 ` David Malcolm
  0 siblings, 1 reply; 14+ messages in thread
From: Andrea Corallo @ 2019-01-01  0:00 UTC (permalink / raw)
  To: gcc-patches, jit; +Cc: nd

[-- Attachment #1: Type: text/plain, Size: 412 bytes --]

Hi all,
I would like to propose this patch to check for the return type of
binary operators to be a numeric type.
Not doing so can lead the compiler into funny crashes.

Does not introduce regressions running make check-jit.

OK for trunk?

Bests
  Andrea

2019-06-09  Andrea Corallo  andrea.corallo@arm.com

* libgccjit.c (gcc_jit_context_new_binary_op): Check result_type to be a
numeric type.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: binary_op_check_result_type.patch --]
[-- Type: text/x-diff; name="binary_op_check_result_type.patch", Size: 587 bytes --]

diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c
index e4f17f8..95a2c02 100644
--- a/gcc/jit/libgccjit.c
+++ b/gcc/jit/libgccjit.c
@@ -1345,6 +1345,10 @@ gcc_jit_context_new_binary_op (gcc_jit_context *ctxt,
     a->get_type ()->get_debug_string (),
     b->get_debug_string (),
     b->get_type ()->get_debug_string ());
+  RETURN_NULL_IF_FAIL_PRINTF1 (
+    result_type->is_numeric (), ctxt, loc,
+    "result_type type: %s is not numeric",
+    result_type->get_debug_string ());
 
   return (gcc_jit_rvalue *)ctxt->new_binary_op (loc, op, result_type, a, b);
 }

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2019-07-04 16:34 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-01  0:00 [PATCH][gcc] libgccjit: check result_type in gcc_jit_context_new_binary_op Andrea Corallo
2019-01-01  0:00 ` David Malcolm
2019-01-01  0:00   ` Andrea Corallo
2019-01-01  0:00     ` David Malcolm
2019-01-01  0:00       ` Andrea Corallo
2019-01-01  0:00         ` David Malcolm
2019-01-01  0:00           ` Andrea Corallo
2019-01-01  0:00           ` Andrea Corallo
2019-01-01  0:00             ` David Malcolm
2019-01-01  0:00               ` Andrea Corallo
2019-01-01  0:00                 ` Andrea Corallo
2019-01-01  0:00                 ` David Malcolm
2019-01-01  0:00                   ` Andrea Corallo
2019-01-01  0:00                     ` Andrea Corallo

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).