From patchwork Thu Sep 7 16:18:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandra Loosemore X-Patchwork-Id: 137652 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ab0a:0:b0:3f2:4152:657d with SMTP id m10csp6101vqo; Thu, 7 Sep 2023 09:19:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGalyccls/VMwLY+nEdbraljVZbaOYnaYzwGaeAywA3aB2CZ7WX4W7tBBM8cvlcNAkUEqvb X-Received: by 2002:a50:ef16:0:b0:51e:5322:a642 with SMTP id m22-20020a50ef16000000b0051e5322a642mr5089909eds.27.1694103571681; Thu, 07 Sep 2023 09:19:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694103571; cv=none; d=google.com; s=arc-20160816; b=NyOfoykqgNqQ0+/xrYigJA7a9CSaocZ2bPLQ62LRhEEf8ZzZm01JBS5sE4trFqsoJr 8+4lgfPpK9FTMl1Z4D0E4jglOS4xWeg9OKLL90RdET4D1J+4O/b1xu/ch9Ei7fxNuUBF +LM4kqTbatusU3V5J+HXTt4jVh4wRlvDSACR9GJWVPNVL20vCKGPhX7k0DsGZudAcEn7 xRRiapq9sLyuTJSwBllKhZ2rydFe3WFAdJFnKzIvTe/4oehxJiSi9Fd1x5nFys3H3l+2 vEVmwhh9EUUvzQohxWYzu7lpOwuS7K/CLwGkXKB19a1SMj4BLqsQNiJScpF2FNYqNlsD kKVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:ironport-sdr :dmarc-filter:delivered-to; bh=Q221P1qbrswk/qeKljoW9MAawOChoYa4YdrzsNw/KHU=; fh=GFHaucKm5PZw/dSNTje+hjMtjErRiHBjhLgFQhMoUr8=; b=CVirqnbUiOwp1sQkxEvpdMKJnPAtv69pJhIS7nfzPlqB+xhyzEDHlbQHhkvczF3aMz 0yM/KJ6X0yv0zfyQFDuw99JOHJdwANPweeNpRzfS/mo4U1uDAqiQkk2SH1UiOxgp+DBJ CGPeDPa5ZQdNHF6giwslb4ZITVgrIdHriE9MHPA3rN7ZPR/OKJtO+i4+Rn/OhuFcX+bg qOuF1q4DftSujPtXYYvWa2UGT5NNX5eLxzQ3KUDYVz55pdvejsNw/9NsGWaOmfmlmSA9 Ck66cKlv/X9E1hPyzqiI1DgIuMXLHka/tWI4uDW/H1ZqAD+Z/L8wTZ419AhEsRqV2XWj i3FA== ARC-Authentication-Results: i=1; mx.google.com; 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" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id a26-20020aa7cf1a000000b005254c2bb872si11099372edy.10.2023.09.07.09.19.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 09:19:31 -0700 (PDT) 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; 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 261CA3857347 for ; Thu, 7 Sep 2023 16:19:19 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id 7B5F53858D1E for ; Thu, 7 Sep 2023 16:18:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7B5F53858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-CSE-ConnectionGUID: TBa2Fb2JSW+Omm6UjMerNA== X-CSE-MsgGUID: fyGkrh6yTOKTO2FFLkwM+A== X-IronPort-AV: E=Sophos;i="6.02,235,1688457600"; d="scan'208";a="16345220" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa4.mentor.iphmx.com with ESMTP; 07 Sep 2023 08:18:51 -0800 IronPort-SDR: OxTc0Hi1pBj2vUKakBJmYFpKr5uKstd4oud6cMIynr1Z9TwcaptrMKuEd4pVSfizkm4HtxMdFO GuihnxSXAWnBZue2hyQKw6yNO2PwoW/d5OjeTbDNaz++B9ABV1x80M0gkm+2Pn3sf7ioQ42JlD iG0swSdx5AN2lemhvtWdSzDa5ezlo3djTBt3xemj3C0KpREWDQvT3XXGXfhfuHgLpyPGBTU3lI sNn7WEty7a0UfokOkQKz1Xc0apWt49p7gkmJbib/la4lWoU9zSkO371TKFSba1tLUz+7ay6QD3 Gok= From: Sandra Loosemore To: CC: Subject: [PATCH] OpenMP: Fix ICE in fixup_blocks_walker [PR111274] Date: Thu, 7 Sep 2023 10:18:37 -0600 Message-ID: <20230907161837.4049453-1-sandra@codesourcery.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-ClientProxiedBy: svr-orw-mbx-12.mgc.mentorg.com (147.34.90.212) To svr-orw-mbx-13.mgc.mentorg.com (147.34.90.213) X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP 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 Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776396346865407183 X-GMAIL-MSGID: 1776396346865407183 This ICE was caused by an invalid assumption that all BIND_EXPRs have a non-null BIND_EXPR_BLOCK. In C++ these do exist and are used for temporaries introduced in expressions that are not full-expressions. Since they have no block to fix up, the traversal can just ignore these tree nodes. gcc/cp/ChangeLog * parser.cc (fixup_blocks_walker): Check for null BIND_EXPR_BLOCK. gcc/testsuite/ChangeLog * g++.dg/gomp/pr111274.C: New test case --- gcc/cp/parser.cc | 5 ++++- gcc/testsuite/g++.dg/gomp/pr111274.C | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/gomp/pr111274.C diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 7811d582b07..15a98019a4a 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -44485,7 +44485,10 @@ fixup_blocks_walker (tree *tp, int *walk_subtrees, void *dp) { tree superblock = *(tree *)dp; - if (TREE_CODE (*tp) == BIND_EXPR) + /* BIND_EXPR_BLOCK may be null if the expression is not a + full-expression; if there's no block, no patching is necessary + for this node. */ + if (TREE_CODE (*tp) == BIND_EXPR && BIND_EXPR_BLOCK (*tp)) { tree block = BIND_EXPR_BLOCK (*tp); if (superblock) diff --git a/gcc/testsuite/g++.dg/gomp/pr111274.C b/gcc/testsuite/g++.dg/gomp/pr111274.C new file mode 100644 index 00000000000..6d3414fc82c --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr111274.C @@ -0,0 +1,15 @@ +// { dg-do "compile" } + +// This example used to ICE in fixup_blocks_walker due to a BIND_EXPR with +// null BIND_EXPR_BLOCK. + +struct _Vector_base { + ~_Vector_base(); +}; +int ColumnSmallestLastOrdering_OMP_i_MaxNumThreads, + ColumnSmallestLastOrdering_OMP_i_MaxDegree; +void ColumnSmallestLastOrdering_OMP() { +#pragma omp for + for (int i = 0; i < ColumnSmallestLastOrdering_OMP_i_MaxNumThreads; i++) + new _Vector_base[ColumnSmallestLastOrdering_OMP_i_MaxDegree]; +}