From patchwork Tue Feb 18 19:26:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Malcolm X-Patchwork-Id: 321627 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 F33132C00D3 for ; Wed, 19 Feb 2014 06:28:34 +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=NAp6zIl63BzB aJAzF1eU/oqDNPMd+ZUbrHXw2XSZyYcj6Hl3SrxWhNdy8qjLMr+DZK5jIdhWCt2y g27vGUz/CsxR4Ghib6FM6zYPcOvVi3dHAN1OS/ug87FC3TXXiKdL950CiQglMDu+ 6942GOoe321WCWhOS3LlSp5In3l2cUA= 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=Y+VjZEUhfWmx8gNdhb HpjVuEO8g=; b=YkAudOeOV9I+o+DOXtpcbseOq71HDjkcir2ZXI9Z4gP0zHbxJl B6W/xmuz1IFaaOGSMwTSYQM04TFV1EfRS1DfdBdVE+AmJavMF6RrKxD11pRw6uBD r+S/zqJuCRIDMR2Ir8H9H6KIU8TGQMjqlLAgYr+3EvTx4XkPKwjszsmnE= Received: (qmail 16484 invoked by alias); 18 Feb 2014 19:28:26 -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 16464 invoked by uid 89); 18 Feb 2014 19:28:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 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; Tue, 18 Feb 2014 19:28:25 +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 s1IJSNmF028301 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 18 Feb 2014 14:28:23 -0500 Received: from surprise.redhat.com (vpn-236-181.phx2.redhat.com [10.3.236.181]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s1IJSMvl014682; Tue, 18 Feb 2014 14:28:22 -0500 From: David Malcolm To: jit@gcc.gnu.org, gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [jit] Avoid using a NULL context when reporting errors Date: Tue, 18 Feb 2014 14:26:55 -0500 Message-Id: <1392751615-3528-1-git-send-email-dmalcolm@redhat.com> X-IsSubscribed: yes Committed to branch dmalcolm/jit: gcc/jit/ * libgccjit.c (gcc_jit_function_new_local): Use the context of the function when reporting errors. (gcc_jit_function_place_forward_label): Likewise. (gcc_jit_function_add_eval): Likewise. (gcc_jit_function_add_assignment_op): Likewise. (gcc_jit_function_add_comment): Likewise. (gcc_jit_function_add_jump): Likewise. --- gcc/jit/ChangeLog.jit | 10 ++++++++++ gcc/jit/libgccjit.c | 24 +++++++++++++++--------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/gcc/jit/ChangeLog.jit b/gcc/jit/ChangeLog.jit index 39706f6..b0e12b1 100644 --- a/gcc/jit/ChangeLog.jit +++ b/gcc/jit/ChangeLog.jit @@ -1,3 +1,13 @@ +2014-02-18 David Malcolm + + * libgccjit.c (gcc_jit_function_new_local): Use the context of the + function when reporting errors. + (gcc_jit_function_place_forward_label): Likewise. + (gcc_jit_function_add_eval): Likewise. + (gcc_jit_function_add_assignment_op): Likewise. + (gcc_jit_function_add_comment): Likewise. + (gcc_jit_function_add_jump): Likewise. + 2014-02-14 David Malcolm * libgccjit++.h (gccjit::type::zero): New method. diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c index e568b3f..b5b3968 100644 --- a/gcc/jit/libgccjit.c +++ b/gcc/jit/libgccjit.c @@ -827,11 +827,12 @@ gcc_jit_function_new_local (gcc_jit_function *func, const char *name) { RETURN_NULL_IF_FAIL (func, NULL, "NULL function"); + gcc::jit::recording::context *ctxt = func->m_ctxt; RETURN_NULL_IF_FAIL (func->get_kind () != GCC_JIT_FUNCTION_IMPORTED, - NULL, + ctxt, "Cannot add locals to an imported function"); - RETURN_NULL_IF_FAIL (type, NULL, "NULL type"); - RETURN_NULL_IF_FAIL (name, NULL, "NULL name"); + RETURN_NULL_IF_FAIL (type, ctxt, "NULL type"); + RETURN_NULL_IF_FAIL (name, ctxt, "NULL name"); return (gcc_jit_lvalue *)func->new_local (loc, type, name); } @@ -853,7 +854,8 @@ gcc_jit_function_place_forward_label (gcc_jit_function *func, gcc_jit_label *lab) { RETURN_IF_NOT_FUNC_DEFINITION (func); - RETURN_IF_FAIL (lab, NULL, "NULL label"); + gcc::jit::recording::context *ctxt = func->m_ctxt; + RETURN_IF_FAIL (lab, ctxt, "NULL label"); func->place_forward_label (loc, lab); } @@ -864,7 +866,8 @@ gcc_jit_function_add_eval (gcc_jit_function *func, gcc_jit_rvalue *rvalue) { RETURN_IF_NOT_FUNC_DEFINITION (func); - RETURN_IF_FAIL (rvalue, NULL, "NULL rvalue"); + gcc::jit::recording::context *ctxt = func->m_ctxt; + RETURN_IF_FAIL (rvalue, ctxt, "NULL rvalue"); return func->add_eval (loc, rvalue); } @@ -901,9 +904,10 @@ gcc_jit_function_add_assignment_op (gcc_jit_function *func, gcc_jit_rvalue *rvalue) { RETURN_IF_NOT_FUNC_DEFINITION (func); - RETURN_IF_FAIL (lvalue, NULL, "NULL lvalue"); + gcc::jit::recording::context *ctxt = func->m_ctxt; + RETURN_IF_FAIL (lvalue, ctxt, "NULL lvalue"); /* FIXME: op is checked by new_binary_op */ - RETURN_IF_FAIL (rvalue, NULL, "NULL rvalue"); + RETURN_IF_FAIL (rvalue, ctxt, "NULL rvalue"); return func->add_assignment_op (loc, lvalue, op, rvalue); } @@ -929,7 +933,8 @@ gcc_jit_function_add_comment (gcc_jit_function *func, const char *text) { RETURN_IF_NOT_FUNC_DEFINITION (func); - RETURN_IF_FAIL (text, NULL, "NULL text"); + gcc::jit::recording::context *ctxt = func->m_ctxt; + RETURN_IF_FAIL (text, ctxt, "NULL text"); func->add_comment (loc, text); } @@ -940,7 +945,8 @@ gcc_jit_function_add_jump (gcc_jit_function *func, gcc_jit_label *target) { RETURN_IF_NOT_FUNC_DEFINITION (func); - RETURN_IF_FAIL (target, NULL, "NULL target"); + gcc::jit::recording::context *ctxt = func->m_ctxt; + RETURN_IF_FAIL (target, ctxt, "NULL target"); func->add_jump (loc, target); }