From patchwork Mon May 15 09:43:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 94052 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp6794437vqo; Mon, 15 May 2023 02:54:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5hSoX09+K8JRFobpPNYGf5aOVqrXvltNOTdB5gYIB+fYMGCygdAM/1iuPnghsT0AAZm2Fb X-Received: by 2002:a17:907:ea2:b0:94f:8605:3f31 with SMTP id ho34-20020a1709070ea200b0094f86053f31mr36082862ejc.42.1684144460826; Mon, 15 May 2023 02:54:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684144460; cv=none; d=google.com; s=arc-20160816; b=Olxg/GuDJdaBSpVEdzBHgDkPNqHuuz5GBRpILwAdaRWtfKzR6VA4QWCtU1vAFK/Iip jooc2MLTXZwRPqwLyiXxRjJQgC7ylwv0jkHKsbYrzLSc+K1wp69I1gDms84KV3trWEzt 8ExaXtldi59b6/GeMY2JGla6WUG53ZsQ8hVhchn2IQicxX2P3XKYbf4J7GaPcUjCDa3i NgRlQXpA4eWMGvaW3/HQxom0xL72TsRQUZT05OwIF4dwxairUjyxohn0uQyRMFNBPI07 NcRKcIxEkL3u6vywBdvS6Un+q+AX1Wm4BdHlr+uJ7wElatus0zAIN2yHxKTkf1dRbQbH lfJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=AwNd/po6vaYCdjJe4l5d8tYGKYMT0YwoJPf7Gep9cXA=; b=TXOXZebEWbGQ/U+EuUKedmBEhgdZrwVry7ikcNAtBwwg8pwxcS2tmXvyMnh6Z24Cmc mgz7RFeaWPoA5V4/Tqq9wpwhTqS4OhFDoerFf3hd4n+BcAjWwXoU8W5gA3hw9VMotIb2 4qBLr0wBZBzmigtaMeVocbBEBkZ6FdsxsFV7iYLo09tVWUhwcTpjDzu6GDE8umG6Higy gx0V9TjtmejQIv22rW8U67jZUAzuBpZlVjGgowkJUKdj75z1p7GuT+CAOTFYAhve48zl SMzjFOWbDyjFaLHvjm+qIQt28JjY7DumD24nKZFtZq7FHpeMs3owKd6HJMoIvBTwwwJW U1SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=j+Zm2gaa; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id jl6-20020a17090775c600b00965cd4ae2c7si13003495ejc.232.2023.05.15.02.54.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 02:54:20 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=j+Zm2gaa; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 429D5388301E for ; Mon, 15 May 2023 09:48:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 429D5388301E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684144099; bh=AwNd/po6vaYCdjJe4l5d8tYGKYMT0YwoJPf7Gep9cXA=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=j+Zm2gaa0JeFt03/lXP+tmSqBU52ZpEx2osVBv0yl1rppkrUAmYGZB1D2vYCI4IVK Eh+cQ/UbewzR0L8BgLDptA60XOxwMdygo4xZ9/qblHfBbuOwa/Jwy3Ntj3secuz/l4 wNWrJtVt6rNP7KfdiCGk/unsm3Ia9Vh7azXFUIZI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by sourceware.org (Postfix) with ESMTPS id E5199385277D for ; Mon, 15 May 2023 09:43:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E5199385277D Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3f42d937d61so63007875e9.3 for ; Mon, 15 May 2023 02:43:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684143828; x=1686735828; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=AwNd/po6vaYCdjJe4l5d8tYGKYMT0YwoJPf7Gep9cXA=; b=ce68XaLpcdN4xUqyq1IgbeGmxPLybHXLBjXEgmc4FAbPplV4cpuIeBXJdSUzjNATJY k55AGfxAQDk6/Edxv2Erw5XOgMhklT1s5PCqd9R7f6g/97TQpvR16ro09jivJab6ZFU3 HagfK2MLeJlfptMYBeR9O9WO7I3Q3nozAQDconRyY8QTgjcieNZbIbscByNPqUS64v1Z uqsc90NWrt+QJJZkNwqjG8zWA5KWvbMuHC+NGAtiqt39SfB9Iclf6AbGWlR9RtMXi/pl 9QKkVMOg7dq+BQiw78AQnFFtDetF0vLodxEEHJdNNIUJ9jYkGn3O1d4JS93rZruiUPTg kD0A== X-Gm-Message-State: AC+VfDxUzOZLJlkqebthnpDClMn0eFcI5BhzTRsUCt3vJdrRhKJxH2WE vI+ADnyqB7sGZKcO5NseBdS90lLKJxzNwpYXAGlt3w== X-Received: by 2002:a05:600c:b47:b0:3f5:bc8:e398 with SMTP id k7-20020a05600c0b4700b003f50bc8e398mr1699646wmr.13.1684143828739; Mon, 15 May 2023 02:43:48 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id m16-20020a7bca50000000b003f1957ace1fsm36333083wml.13.2023.05.15.02.43.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 02:43:48 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED] ada: Remove redundant protection against empty lists Date: Mon, 15 May 2023 11:43:46 +0200 Message-Id: <20230515094346.1408423-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: =?utf-8?q?Marc_Poulhi=C3=A8s?= Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765953462191265594?= X-GMAIL-MSGID: =?utf-8?q?1765953462191265594?= From: Piotr Trojanek Calls to First on No_List intentionally return Empty node, so explicit guards against No_List are unnecessary. Code cleanup; semantics is unaffected. gcc/ada/ * sem_util.adb (New_Copy_Tree): Remove redundant calls to Present. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_util.adb | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 5ec0140d090..eb0d08a1851 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -24167,14 +24167,12 @@ package body Sem_Util is -- Note that the element of a syntactic list is always a node, never -- an entity or itype, hence the call to Visit_Node. - if Present (List) then - Elmt := First (List); - while Present (Elmt) loop - Visit_Node (Elmt); + Elmt := First (List); + while Present (Elmt) loop + Visit_Node (Elmt); - Next (Elmt); - end loop; - end if; + Next (Elmt); + end loop; end Visit_List; ---------------- @@ -24206,8 +24204,7 @@ package body Sem_Util is -- If the node is a block, we need to process all declarations -- in the block and make new entities for each. - if Nkind (N) = N_Block_Statement and then Present (Declarations (N)) - then + if Nkind (N) = N_Block_Statement then declare Decl : Node_Id := First (Declarations (N));