From patchwork Fri Feb 9 15:30:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans-Peter Nilsson X-Patchwork-Id: 198951 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp932343dyd; Fri, 9 Feb 2024 07:31:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IHMvISeMGlYGlsXhg9CqtYTiaILdEGaaGX5ulMjmLl2CU96y21Y9r2mjPne6hbl+1ea3s31 X-Received: by 2002:a0c:e190:0:b0:681:963:ffd6 with SMTP id p16-20020a0ce190000000b006810963ffd6mr1828017qvl.58.1707492694840; Fri, 09 Feb 2024 07:31:34 -0800 (PST) ARC-Seal: i=3; a=rsa-sha256; t=1707492694; cv=pass; d=google.com; s=arc-20160816; b=H9AQlSKnPFNB+PbMofo/m4K+E33aBFkwGR9iIc1UaYSqkWcsvRE8mqHqgSIlnaAlAg 6KkBQkhxxeae9Aa7TU97BQrawtLtlGwUi/eNS5MR+Eimit4f/czUdDgjn/PGbHbGOmBS Seb25SVVeuQnZ54Ok5f8kc9EU4eLVrO705iYW1v+XRQ7ldnj/8ffluZ1LTlNZbiMBLru jkKIlq1GwnUXEcbsI4trsROV+v4iOx8SZYKsSn+JI7s7iyDADZPT53N9TzKcU8jLSe+9 vE70/BRHQ8v/G+6/g3/5DkNLea+L2ELleCtJw1BEX2bU99ULet1mq/XuGtLts23b1BCG tRag== ARC-Message-Signature: i=3; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:date:message-id:references :content-transfer-encoding:mime-version:subject:in-reply-to:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=vAWHZdh/t4dDtxuukPhqnFxxEejwDm8LAY7BvQ4n+/A=; fh=bMO8UsjgfDeTioaxOS1k7bS5/GxT1pcDwAWUuuguAX0=; b=yQI7uxsKVSGjnztQm2SRhtmAi3sTwrd2Nmraytq+afa/hFVZ/jYqBLFJr4L3VexdCv T+6OprINYsg6oMqS6qOAQN5X08HEb19WNV485hBTj4NwN6zFBNb/qyHaWYE3c9vcyOp7 AIVUe23JRIW8XCRCTpWL9fz9SzSNlZ4e3mBubfxt2TNEvmWcLOo2GDQMbW42BAZ0w70u uBzNxmWV93Nvvft6yTtJEMusLBD5KiP3IIh8WyRK4jQiiv8D24lMd5MQUrgFX8fE35XB Giqj7bG44ZNywEW1y963FWowrqEuv4UGvLIUxiAxWHLPo6OipSFSMEvYH/Fv7T3856uh Zsog==; dara=google.com ARC-Authentication-Results: i=3; mx.google.com; dkim=pass header.i=@axis.com header.s=selector1 header.b=I5ALelBN; arc=pass (i=2); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com X-Forwarded-Encrypted: i=3; AJvYcCUKZcMP0XvzVFCRhmvKqIzzuPSp1BMKAQyrLpKw44/ozTu3o0+gZIfkbfoFoHSrsWRPcJOpamOBABIqNkXnvG9sG/lE9w== Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id gv12-20020a056214262c00b0068cd5aa1600si1292335qvb.499.2024.02.09.07.31.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 07:31:34 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@axis.com header.s=selector1 header.b=I5ALelBN; arc=pass (i=2); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 75AC938582B0 for ; Fri, 9 Feb 2024 15:31:34 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2043.outbound.protection.outlook.com [40.107.8.43]) by sourceware.org (Postfix) with ESMTPS id 541603858403 for ; Fri, 9 Feb 2024 15:30:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 541603858403 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=axis.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=axis.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 541603858403 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.8.43 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1707492649; cv=pass; b=sVIRN8/WaCiIgYGt5yvTGjuO94uy1/apT/fg1kaHh81kQZOUJT/rN/LRUXu8Z2Ujq9dmGlPcLMYyXztMlRcC5jsQ/RdDjkOcBxiccxIxQ6tO1OC8k/shYHytShuZsE/tIE2c+TPI/T9AaLefxpodVT7CCmNlynESWWjYEcd9t9o= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1707492649; c=relaxed/simple; bh=BklFVFvxOD6z2RF7xKkTsX+7yylQ5/yXLjyfN3UhIKU=; h=DKIM-Signature:From:To:Subject:MIME-Version:Message-ID:Date; b=MFSjjNr8Gk+TyN1xs4BdVztxL/xIGSlMygv0UvRBmcBweOrzEQQq/IrT+MhgpFTMNzwh1ioTLA7upOA0Eewwkyg+Gx3VHr2PREQAFRI3f3nSCCfw+km3cYPSXNvoxhhOm3BPPcdq8+cOaWrcbI1Am1QO+wSGr9igzGMF5HxrE/4= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V1gmxf3fXL1MIFjhvb/61+fJ+6MlFGz0rjS0p2Lho+BHzCuCWGW8N9pMZAF7PWLC952MxMuPEzPgHt9xMU6LAVl1PFsz6icOcrbroU7mBEtA8zTVRXpPGtsEsAWbRmFZD32+DuolP8AROv7dMpouVGEjPFby9AoJdrszR4vk3l17kq2S3Vl+quCe4EjDDVyx+Izz2CMPJZQGhONiaKKAeCxHCHeGoZ5eOM4MZ+n/a3wZ/RVO92EdxGSRvYgqrM2O20qGQFsfadFGQZywbm1aaz3Wo/gwwCEBhsTCDVkAMC4WQEu+IFVxYsFOeaU5zWaC9jmITq/Sw3Pc7eEhnzNj9Q== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=vAWHZdh/t4dDtxuukPhqnFxxEejwDm8LAY7BvQ4n+/A=; b=d0T8XGR3DssEXTVC97OQ7aAvupuvW3PRyF3+JnnsaaNPArQC3B8tFRDvwxGv5G9ACZed8iYiqiZCQECYHjhek5Nve7XzotT+oGnw+KmzkKRCa/lkCx9vT6IUzt5z3Oamzs9wcd+BUS/u8aaS4QDSxU39jHGGk8zXJclLxiDLb6Et8j33s9ovJcMptW5psElidFilGKD4QWLgV1iIWf9IqKf70ea1JTldhARS7U0k5V7SCpiBfW7+0VveT5v2BPWVddUMTkJmVmX44Mb0GQhdd8VlOSSEEMfknM1GHQPPfB4mrG4bV1d8pyTTmtiS7TZcEnn7mB8NLYDA6ywHlDmj2Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 195.60.68.100) smtp.rcpttodomain=gcc.gnu.org smtp.mailfrom=axis.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=axis.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vAWHZdh/t4dDtxuukPhqnFxxEejwDm8LAY7BvQ4n+/A=; b=I5ALelBNvIJ1kNJVKni6TP3UAAtX992Pjsfu2SSSWuQxq3Sf/ec4y+r6gCfyR8lMmP/5lSCC24eUxZAvzlEYzXvnzgjo/1LxrUtL2aj+Q2Je9VcFT4BzvjJMqB9shZrcH4ubkQmYJ0XTRJFPNuYy7gE0c4is7T/2UXQFu1tA+9I= Received: from DUZPR01CA0050.eurprd01.prod.exchangelabs.com (2603:10a6:10:469::20) by DB9PR02MB8177.eurprd02.prod.outlook.com (2603:10a6:10:308::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.27; Fri, 9 Feb 2024 15:30:44 +0000 Received: from DB5PEPF00014B8E.eurprd02.prod.outlook.com (2603:10a6:10:469:cafe::6a) by DUZPR01CA0050.outlook.office365.com (2603:10a6:10:469::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.24 via Frontend Transport; Fri, 9 Feb 2024 15:30:44 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 195.60.68.100) smtp.mailfrom=axis.com; dkim=none (message not signed) header.d=none;dmarc=fail action=none header.from=axis.com; Received-SPF: Fail (protection.outlook.com: domain of axis.com does not designate 195.60.68.100 as permitted sender) receiver=protection.outlook.com; client-ip=195.60.68.100; helo=mail.axis.com; Received: from mail.axis.com (195.60.68.100) by DB5PEPF00014B8E.mail.protection.outlook.com (10.167.8.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7249.19 via Frontend Transport; Fri, 9 Feb 2024 15:30:43 +0000 Received: from se-mail01w.axis.com (10.20.40.7) by se-mail02w.axis.com (10.20.40.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 9 Feb 2024 16:30:43 +0100 Received: from se-intmail01x.se.axis.com (10.0.5.60) by se-mail01w.axis.com (10.20.40.7) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Fri, 9 Feb 2024 16:30:43 +0100 Received: from pchp3.se.axis.com (pchp3.se.axis.com [10.88.21.53]) by se-intmail01x.se.axis.com (Postfix) with ESMTP id 7D56413B55; Fri, 9 Feb 2024 16:30:43 +0100 (CET) Received: by pchp3.se.axis.com (Postfix, from userid 171) id 67D4620422; Fri, 9 Feb 2024 16:30:43 +0100 (CET) From: Hans-Peter Nilsson To: Jason Merrill CC: , In-Reply-To: <3dec1777-c631-4ba7-9e9a-e7b88578c1b0@redhat.com> (message from Jason Merrill on Wed, 7 Feb 2024 16:32:57 -0500) Subject: [PATCH v3]: testcases for "ICE for unknown parameter to constexpr'd switch-statement, PR113545" MIME-Version: 1.0 References: <20240122170232.C836A20439@pchp3.se.axis.com> <20240207002349.54FD220415@pchp3.se.axis.com> <3dec1777-c631-4ba7-9e9a-e7b88578c1b0@redhat.com> Message-ID: <20240209153043.67D4620422@pchp3.se.axis.com> Date: Fri, 9 Feb 2024 16:30:43 +0100 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DB5PEPF00014B8E:EE_|DB9PR02MB8177:EE_ X-MS-Office365-Filtering-Correlation-Id: 2ec10038-a52f-4c2e-4c01-08dc298414bf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: S1j2dExTrr1A9OY1YL7B2O608z63BIkP/tWOfQ+xCNpGWto5aQ2QKDbOTMTZJqDAfIPliVVq7zHZrU5W12Xzl81lAhmzvz/h3/qximv/vTjB8rG91ajRohmTA8LxYiIg+B8n6ce2F0F6vkJALc+r/3YxWpW2hQ4mDXgZtv/V1JCcTywRoFMOg0dbgcYHSbPm1A8HJzekuJWkMspdrAohm2A+qN8XoxySeNNk6uxSxcVf9KjKT/O4ya1AHqk3ZS+z70926lnHSozI6ZAuE6ONuNbUq2U+DK9ClsN2kNdOLCQJKMAkfuFWSA80+rRiV/d1j8nqEFC4nWUsAnruHOI2RTf7787XsBoOAQ9o3B0KNkIKF4Y+shGIr0PVpxTwBt682Z13iWSivMBpWH0M8byG8/WB1LZYywOcQdgm+c62OqdDgW/cB9HGFCmi3G5Svqvn7xHy8gLFiaJz0q/MWt9VdmEaCeSkabyGfo79z7rOwx5g25vipwENaezmBMT5+ulYuvXglakXgM3Xi35lmEssJiQ14is3vlEyZa+x13C4jNCiRBWGqmGZVSb5zxq0fyPpLpJvsrhnGNw9YfDvTmXx2oJbYQroJjt97s08A61g7wM= X-Forefront-Antispam-Report: CIP:195.60.68.100; CTRY:SE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.axis.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(136003)(39860400002)(396003)(376002)(346002)(230922051799003)(64100799003)(451199024)(1800799012)(82310400011)(186009)(36840700001)(40470700004)(46966006)(41300700001)(478600001)(2906002)(5660300002)(4326008)(6916009)(8936002)(70206006)(70586007)(8676002)(54906003)(42186006)(316002)(26005)(83380400001)(1076003)(81166007)(82740400003)(6266002)(33656002)(356005)(426003)(336012); DIR:OUT; SFP:1101; X-OriginatorOrg: axis.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2024 15:30:43.9489 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2ec10038-a52f-4c2e-4c01-08dc298414bf X-MS-Exchange-CrossTenant-Id: 78703d3c-b907-432f-b066-88f7af9ca3af X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=78703d3c-b907-432f-b066-88f7af9ca3af; Ip=[195.60.68.100]; Helo=[mail.axis.com] X-MS-Exchange-CrossTenant-AuthSource: DB5PEPF00014B8E.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR02MB8177 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790392531149811275 X-GMAIL-MSGID: 1790435860060978589 Bah. Linaro's CI didn't like that there were UNRESOLVEDs due to this patch. Running it "as usual" didn't show anything suspicious. Sure, there were "# of unresolved testcases 3" in the summary (see v2), but no error or other special message from dejagnu. Perhaps there could be a way to have dg-ice automatically downgrade a dg-do run that failed due to the ICE to a dg-do compile (or just not emit the UNRESOLVED note), but pragmatically, this is a rare enough case to not bother. It looks like these were the only UNRESOLVEDs in that CI run, so I'm just going to make a mental note and move on. For more comments, please see v2 of this patch. v3: Change dg-do run to dg-do compile to avoid an UNRESOLVED. Tested as with v2. Ok to commit? -- >8 -- Test-cases, with constexpr-reinterpret3.C dg-ice:ing the PR c++/113545 bug. Regarding the request in the comment, a dg-do run when there's an ICE will cause some CI's to signal an error for the run being "UNRESOLVED" (compilation failed to produce executable). Note that dejagnu (1.6.3) itself doesn't consider this an error. gcc/testsuite: PR c++/113545 * g++.dg/cpp1y/constexpr-reinterpret3.C, g++.dg/cpp1y/constexpr-reinterpret4.C: New tests. --- .../g++.dg/cpp1y/constexpr-reinterpret3.C | 56 +++++++++++++++++++ .../g++.dg/cpp1y/constexpr-reinterpret4.C | 54 ++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp1y/constexpr-reinterpret3.C create mode 100644 gcc/testsuite/g++.dg/cpp1y/constexpr-reinterpret4.C diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-reinterpret3.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-reinterpret3.C new file mode 100644 index 000000000000..6c396bff72b6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-reinterpret3.C @@ -0,0 +1,56 @@ +// PR c++/113545 +// { dg-do run { target c++14 } } +// Please change the above "dg-do compile" to "dg-do run" when the ICE is resolved. +// { dg-ice "PR112545 - constexpr function with switch called for reinterpret_cast" } + +char foo; + +// This one caught a call to gcc_unreachable in +// cp/constexpr.cc:label_matches, when passed a convert_expr from the +// cast in the call. +constexpr unsigned char swbar(__UINTPTR_TYPE__ baz) +{ + switch (baz) + { + case 13: + return 11; + case 14: + return 78; + case 2048: + return 13; + default: + return 42; + } +} + +// For reference, the equivalent* if-statements. +constexpr unsigned char ifbar(__UINTPTR_TYPE__ baz) +{ + if (baz == 13) + return 11; + else if (baz == 14) + return 78; + else if (baz == 2048) + return 13; + else + return 42; +} + +__attribute__ ((__noipa__)) +void xyzzy(int x) +{ + if (x != 42) + __builtin_abort (); +} + +int main() +{ + unsigned const char c = swbar(reinterpret_cast<__UINTPTR_TYPE__>(&foo)); + xyzzy(c); + unsigned const char d = ifbar(reinterpret_cast<__UINTPTR_TYPE__>(&foo)); + xyzzy(d); + unsigned const char e = swbar((__UINTPTR_TYPE__) &foo); + xyzzy(e); + unsigned const char f = ifbar((__UINTPTR_TYPE__) &foo); + xyzzy(f); +} diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-reinterpret4.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-reinterpret4.C new file mode 100644 index 000000000000..9aaa6e463bc6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-reinterpret4.C @@ -0,0 +1,54 @@ +// PR c++/113545 +// { dg-do compile { target c++14 } } + +char foo; + +// This one caught a call to gcc_unreachable in +// cp/constexpr.cc:label_matches, when passed a convert_expr from the +// cast in the call. +constexpr unsigned char swbar(__UINTPTR_TYPE__ baz) +{ + switch (baz) + { + case 13: + return 11; + case 14: + return 78; + case 2048: + return 13; + default: + return 42; + } +} + +// For reference, the equivalent* if-statements. +constexpr unsigned char ifbar(__UINTPTR_TYPE__ baz) +{ + if (baz == 13) + return 11; + else if (baz == 14) + return 78; + else if (baz == 2048) + return 13; + else + return 42; +} + +__attribute__ ((__noipa__)) +void xyzzy(int x) +{ + if (x != 42) + __builtin_abort (); +} + +int main() +{ + unsigned constexpr char c = swbar(reinterpret_cast<__UINTPTR_TYPE__>(&foo)); // { dg-error "conversion from pointer type" } + xyzzy(c); + unsigned constexpr char d = ifbar(reinterpret_cast<__UINTPTR_TYPE__>(&foo)); // { dg-error "conversion from pointer type" } + xyzzy(d); + unsigned constexpr char e = swbar((__UINTPTR_TYPE__) &foo); // { dg-error "conversion from pointer type" } + xyzzy(e); + unsigned constexpr char f = ifbar((__UINTPTR_TYPE__) &foo); // { dg-error "conversion from pointer type" } + xyzzy(f); +}