public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][gcc] libgccjit: check result_type in gcc_jit_context_new_binary_op
@ 2019-06-10  9:15 Andrea Corallo
  2019-06-18 22:31 ` David Malcolm
  0 siblings, 1 reply; 15+ messages in thread
From: Andrea Corallo @ 2019-06-10  9:15 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] 15+ messages in thread

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

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-10  9:15 [PATCH][gcc] libgccjit: check result_type in gcc_jit_context_new_binary_op Andrea Corallo
2019-06-18 22:31 ` David Malcolm
2019-06-24 15:30   ` Andrea Corallo
2019-06-24 15:52     ` David Malcolm
2019-06-24 16:37       ` Andrea Corallo
2019-06-24 20:44         ` David Malcolm
2019-06-24 21:50           ` Andrea Corallo
2019-06-25  8:11           ` Andrea Corallo
2019-06-26 13:19             ` David Malcolm
2019-06-26 15:05               ` Andrea Corallo
2019-07-01  8:49                 ` Andrea Corallo
2019-07-02 14:46                 ` David Malcolm
2019-07-02 14:55                   ` Kyrill Tkachov
2019-07-02 15:28                   ` Andrea Corallo
2019-07-04 17:47                     ` 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).