From patchwork Thu Jul 18 14:20:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Corallo X-Patchwork-Id: 1133749 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-505278-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Oghcu9vE"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="PNWKfShb"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.b="PNWKfShb"; dkim-atps=neutral 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 45qGX54kZZz9sBt for ; Fri, 19 Jul 2019 00:21:02 +1000 (AEST) 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:content-type:mime-version; q=dns; s=default; b=D/xirj+GQvbBLfB3bLrKx7FrxNTxbknQfcglu8ohitNLfTruA3 5jSznBqW+Uk2LvBxLY7vrs4yE8L7LTyc3XnvBVvIcesLYHhgPRSQ/XZ82FJbtDll HQirLRO7qoLIqNEhNiY0ZtzyOlJmrDhi2sE0CZXNU7YDCUppT/ofwcjEM= 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:content-type:mime-version; s= default; bh=WTEZ02rxocq8YeazBM6Z7R7ALE4=; b=Oghcu9vEt+QWeuA3rQ0L NxWn+bEydtfk/W0Ocz8W3EEpwuwT9We9uWbh2xRNT6VtuAwLoeG8o6bFJ7pf4B/m zTIDPlKEHQVz9GalhOfWQbjy7uCd5EeNLMt3gb0qv1o7hs4T7FJM3Jt7Y9Uf+jUV aECy4Qb/htP3qBxFkC0FpxE= Received: (qmail 54752 invoked by alias); 18 Jul 2019 14:20:53 -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 54735 invoked by uid 89); 18 Jul 2019 14:20:53 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: EUR01-HE1-obe.outbound.protection.outlook.com Received: from mail-eopbgr130072.outbound.protection.outlook.com (HELO EUR01-HE1-obe.outbound.protection.outlook.com) (40.107.13.72) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 18 Jul 2019 14:20:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DPXl9wYdsSjgT4uxT83y5ctbZLaGO5ipV85qnegsQwk=; b=PNWKfShb9Wx/z2SzEpWWEXSG5Xge/IWUJuWxMoImNiUADSIOCRP1OeDUVmLUciLqmWI7PuYo6oOM3sfpNmhlOMqoOR9tfGP5jXxPt0Ix4Fs8U5fSEjWgKT3fJ20G4itNQf4B3MYTbPlD6OLu4+FIouD8uHPfz0ePiRox9QatvO4= Received: from VI1PR08CA0172.eurprd08.prod.outlook.com (2603:10a6:800:d1::26) by AM5PR0802MB2594.eurprd08.prod.outlook.com (2603:10a6:203:99::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2073.14; Thu, 18 Jul 2019 14:20:41 +0000 Received: from VE1EUR03FT025.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::201) by VI1PR08CA0172.outlook.office365.com (2603:10a6:800:d1::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2073.11 via Frontend Transport; Thu, 18 Jul 2019 14:20:41 +0000 Authentication-Results: spf=temperror (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; gcc.gnu.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; gcc.gnu.org; dmarc=temperror action=none header.from=arm.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT025.mail.protection.outlook.com (10.152.18.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2052.18 via Frontend Transport; Thu, 18 Jul 2019 14:20:40 +0000 Received: ("Tessian outbound 350ce6c32571:v24"); Thu, 18 Jul 2019 14:20:40 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 45b6f9d2f94ae8d7 X-CR-MTA-TID: 64aa7808 Received: from 8e08a2d6b4be.1 (cr-mta-lb-1.cr-mta-net [104.47.4.50]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 1894E999-FBBF-405E-8FE6-7BD65C1643F1.1; Thu, 18 Jul 2019 14:20:34 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-am5eur02lp2050.outbound.protection.outlook.com [104.47.4.50]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 8e08a2d6b4be.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Thu, 18 Jul 2019 14:20:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WmonyXuW3RSpK5eHAqejEl28gFgT1GlaI35rp0HBTJZ+bXh6gi+qBpcwrlq6Sw8pHUzvX6345UdNWcT4JY2DiQWML3uXc1Us1F8ddkDS3NIp94SjK7nON92oi1005pqouQagZGK9OS9Vca3crFbF+G+5AV6G1nHjeAkzCm4plDCE8ZBghvur7jo9MRSp2jI9c7YYtFqWBa+hGNgesXSBuztQlxqQpmh0EJMWlpdt7Q/Vowi/t4kewHWiWETHI8IedIWMs542klTIwAJujc+x7QlsOhgsPt6WPdayEEmmdB8VwSakESZCdVXhUssz8oTubbzMyedxG0TYpAtNcxo/3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DPXl9wYdsSjgT4uxT83y5ctbZLaGO5ipV85qnegsQwk=; b=V4aru3SaD97kZ9iEE++HYDGgX5BHwTy4uK5qjVSQBBx3DhQPKp0ekQ7ob3+9s2dOa6pwE31FnLDqdSMs+TJUkzaPnOiNpAOvdbqSxE8HMhxIpK77Iz8JxiHSOOg2iOBagFwtG9yylvV3MeSe1xn79sylOoLfld+rmEUm1mEHamNC6iHaCqLBSii1M5MpqzDbBm2I6KJSqhWrixs/Wy5FbdU1hnCH0AEWbZPCML49zR+WlBaJsESyEhwiVlkfgrYqhmP4s36CaUAENeQ2QWMcXF/NYv3K7xvJpwHdpP0aeGEyFAppR9H401OlV4BVgqsIRafcMytD9jmGLa40LopHSA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DPXl9wYdsSjgT4uxT83y5ctbZLaGO5ipV85qnegsQwk=; b=PNWKfShb9Wx/z2SzEpWWEXSG5Xge/IWUJuWxMoImNiUADSIOCRP1OeDUVmLUciLqmWI7PuYo6oOM3sfpNmhlOMqoOR9tfGP5jXxPt0Ix4Fs8U5fSEjWgKT3fJ20G4itNQf4B3MYTbPlD6OLu4+FIouD8uHPfz0ePiRox9QatvO4= Received: from VE1PR08MB5070.eurprd08.prod.outlook.com (20.179.29.148) by VE1PR08MB5120.eurprd08.prod.outlook.com (20.179.30.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2073.14; Thu, 18 Jul 2019 14:20:33 +0000 Received: from VE1PR08MB5070.eurprd08.prod.outlook.com ([fe80::34f5:a093:3356:52f5]) by VE1PR08MB5070.eurprd08.prod.outlook.com ([fe80::34f5:a093:3356:52f5%7]) with mapi id 15.20.2094.011; Thu, 18 Jul 2019 14:20:33 +0000 From: Andrea Corallo To: "jit@gcc.gnu.org" , "gcc-patches@gcc.gnu.org" CC: nd Subject: [PATCH][gcc] libgccjit: check result_type in gcc_jit_context_new_unary_op Date: Thu, 18 Jul 2019 14:20:33 +0000 Message-ID: Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=Andrea.Corallo@arm.com; X-Microsoft-Antispam-Untrusted: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(49563074)(7193020); SRVR:VE1PR08MB5120; x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:2000;OLM:2000; X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(39860400002)(346002)(376002)(396003)(366004)(136003)(189003)(53754006)(54534003)(199004)(66476007)(26005)(66946007)(64756008)(66446008)(68736007)(86362001)(66616009)(102836004)(316002)(99936001)(53936002)(8936002)(36756003)(71190400001)(7736002)(4744005)(66556008)(386003)(6506007)(99286004)(305945005)(2501003)(486006)(476003)(52116002)(4326008)(25786009)(186003)(478600001)(256004)(450100002)(2616005)(71200400001)(44832011)(6512007)(110136005)(81166006)(8676002)(6436002)(6486002)(81156014)(3846002)(5660300002)(14454004)(66066001)(2906002)(6116002); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB5120; H:VE1PR08MB5070.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info-Original: cDr1gl5lmRKWppy7D+mD6EYmuOFTjW8CKp4v2BfqeAHglnpXpFlQQIGCDMvlR+mXhgz0qQsXxahTQ8niJFSmGKDDUo4HBn10fcalZ1KMZydu9rIveVnOKuLDZ7KQi38bVe8Im4VwI4tATt5ou6+7PBwesmnfelEWAlhFs/iIr+Xx99PStc1ywIoYmKQNkmBzt8phwq7HfgGUkxhLzxlJW5yqng4bYbhgCd+QikuaseQQo23FQ7uACGG09yD3I1PKW74HOVXFPo+7Yj0xYEnulZqUiZED5bRmBoRmeyFd9VxRD/3BPo20fx+hguI+NmJiMWL3D7tS/9DUESr3zFlcV2wuOhjYNq/5p0rhlxQ39F/K9G0w8SEFcHUrNaHp02DqYNPhzUQFm/WO1qFIE7BFiJIidmmAuG2jBMHTNKVU45I= MIME-Version: 1.0 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Andrea.Corallo@arm.com; X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT025.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 23257cce-ada1-42ff-1038-08d70b8b183c Hi all, I've just realized that what we has been done recently for gcc_jit_context_new_binary_op should be done also for the unary version. This patch checks at record time for the result type of gcc_jit_context_new_unary_op to be numeric type plus add a testcase for the new check. make check-jit runs clean Is it okay for trunk? Bests Andrea gcc/jit/ChangeLog 2019-07-18 Andrea Corallo * libgccjit.c (gcc_jit_context_new_unary_op): Check result_type to be a numeric type. * libgccjit.c (gcc_jit_context_new_binary_op): Fix nit in error message. gcc/testsuite/ChangeLog 2019-07-04 Andrea Corallo * jit.dg/test-error-gcc_jit_context_new_unary_op-bad-res-type.c: New testcase. * jit.dg/test-error-gcc_jit_context_new_binary_op-bad-res-type.c: Fix nit in error message. diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c index 23e83e2..bea840f 100644 --- a/gcc/jit/libgccjit.c +++ b/gcc/jit/libgccjit.c @@ -1336,6 +1336,12 @@ gcc_jit_context_new_unary_op (gcc_jit_context *ctxt, "unrecognized value for enum gcc_jit_unary_op: %i", op); RETURN_NULL_IF_FAIL (result_type, ctxt, loc, "NULL result_type"); + RETURN_NULL_IF_FAIL_PRINTF3 ( + result_type->is_numeric (), ctxt, loc, + "gcc_jit_unary_op %i with operand %s " + "has non-numeric result_type: %s", + op, rvalue->get_debug_string (), + result_type->get_debug_string ()); RETURN_NULL_IF_FAIL (rvalue, ctxt, loc, "NULL rvalue"); return (gcc_jit_rvalue *)ctxt->new_unary_op (loc, op, result_type, rvalue); @@ -1388,7 +1394,7 @@ gcc_jit_context_new_binary_op (gcc_jit_context *ctxt, RETURN_NULL_IF_FAIL_PRINTF4 ( result_type->is_numeric (), ctxt, loc, "gcc_jit_binary_op %i with operands a: %s b: %s " - "has non numeric result_type: %s", + "has non-numeric result_type: %s", op, a->get_debug_string (), b->get_debug_string (), result_type->get_debug_string ()); diff --git a/gcc/testsuite/jit.dg/test-error-gcc_jit_context_new_binary_op-bad-res-type.c b/gcc/testsuite/jit.dg/test-error-gcc_jit_context_new_binary_op-bad-res-type.c index abadc9f..d2a0963 100644 --- a/gcc/testsuite/jit.dg/test-error-gcc_jit_context_new_binary_op-bad-res-type.c +++ b/gcc/testsuite/jit.dg/test-error-gcc_jit_context_new_binary_op-bad-res-type.c @@ -36,6 +36,6 @@ verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) /* Verify that the correct error message was emitted. */ CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt), "gcc_jit_context_new_binary_op: gcc_jit_binary_op 1 with" - " operands a: (int)1 b: (int)2 has non numeric " + " operands a: (int)1 b: (int)2 has non-numeric " "result_type: void *"); } diff --git a/gcc/testsuite/jit.dg/test-error-gcc_jit_context_new_unary_op-bad-res-type.c b/gcc/testsuite/jit.dg/test-error-gcc_jit_context_new_unary_op-bad-res-type.c new file mode 100644 index 0000000..f547974 --- /dev/null +++ b/gcc/testsuite/jit.dg/test-error-gcc_jit_context_new_unary_op-bad-res-type.c @@ -0,0 +1,37 @@ +#include +#include + +#include "libgccjit.h" + +#include "harness.h" + +/* Try to create an unary operator with invalid result type. */ + +void +create_code (gcc_jit_context *ctxt, void *user_data) +{ + gcc_jit_type *int_type = + gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_INT); + gcc_jit_type *void_ptr_type = + gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_VOID_PTR); + + gcc_jit_context_new_unary_op ( + ctxt, + NULL, + GCC_JIT_UNARY_OP_LOGICAL_NEGATE, + void_ptr_type, + gcc_jit_context_new_rvalue_from_int (ctxt, + int_type, + 1)); +} + +void +verify_code (gcc_jit_context *ctxt, gcc_jit_result *result) +{ + CHECK_VALUE (result, NULL); + + /* Verify that the correct error message was emitted. */ + CHECK_STRING_VALUE (gcc_jit_context_get_first_error (ctxt), + "gcc_jit_context_new_unary_op: gcc_jit_unary_op 2 with " + "operand (int)1 has non-numeric result_type: void *"); +}