From patchwork Fri Feb 28 23:38:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 325366 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id DBFB72C00BC for ; Sat, 1 Mar 2014 10:40:01 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id; q=dns; s=default; b=SD/tykqWxfPx A1KSu+y+9M7lupqmVE3MDuqZ2iDqGciiHWs6ZjXAFl5cQcRCKkQet1fyabWipZOu cziEvQSEsQlaY4byB+tOwy3+oIvy27gtpq8sN6txVPN03UqOwQY9x00Z7q9922zz ozFctE/KUHPzD7K4tRo93W9flNXGu08= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id; s=default; bh=b2Na9nC1nVVJNjFloM bmApARJZo=; b=mYBzKyUZkFz+TrcvRuGzQ3gLBStzT4NCOkVvOBpdF39Hq/NcDE /RXxKXvmJyu/f5jv6CY1befw1yIh1jaU28EBMOEHnKtipPgzsTiIxHNYLC+cz3ei YRM56uBIymLPsnYEylYAJXa0pYipwtX+RdcqkZfimsLAp6nWqI+aRbzKw= Received: (qmail 2543 invoked by alias); 28 Feb 2014 23:39:54 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 2514 invoked by uid 89); 28 Feb 2014 23:39:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 28 Feb 2014 23:39:52 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s1SNdoWH009085 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 28 Feb 2014 18:39:50 -0500 Received: from surprise.redhat.com (vpn-237-140.phx2.redhat.com [10.3.237.140]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s1SNdmCd004334; Fri, 28 Feb 2014 18:39:48 -0500 From: David Malcolm To: jit@gcc.gnu.org, gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [jit] Add typechecking to binary ops and comparisons Date: Fri, 28 Feb 2014 18:38:13 -0500 Message-Id: <1393630693-9285-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes 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 + * 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 + * 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); }