From patchwork Fri May 26 07:36:08 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: 99360 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp293305vqr; Fri, 26 May 2023 00:48:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ56VgONCRvjIpdzK1ccY25/drGdMKn0/3ZyF5W1SLetmyJQVAPRnAb5APzynP+YDpStYvpe X-Received: by 2002:a50:ed12:0:b0:504:8905:5218 with SMTP id j18-20020a50ed12000000b0050489055218mr934542eds.1.1685087301962; Fri, 26 May 2023 00:48:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685087301; cv=none; d=google.com; s=arc-20160816; b=PzxK575FykoDHXPIMcncBErsrDkM9c9+wyRjwncB3K7ENcKhOM7Cv1jvbWQk77IoYF h3DCUKPpORhLxX5VsG7bGdf79bLLWqt/SRZmpue10EDT0rww9oNeW77xM7NWmqFiYneK VCvBnjSWIAu0ijinZdDv0CcfbXY5b5ftKATMHFTcI2nN59Q5TNs2UZTH9OQTCvvppPh7 sHk6ZiiymyEzokf2g7+LywR/ezbGRmFv7cfhRiXlcvmzHkkj+9Ph5w0Yyw+OodLtAWDA Qf+C2ZWkgv3IxaIidry/oiMg1TpT+EiI+P7Q0iGkG3M0KYyES2TBK1TuUpccGzFB1jw0 oLtw== 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=tMPotch9Hl1zZADiS8CtwSOGk0bpMpUzvW/5vgmgZGU=; b=iCIDq/HYSmwKxmSNQVoQ4uaj7F+nN4WfeTE8jcwu++qpN24lBBsf/QKn5VM6qQF5aT MV0RjHNH+c/Db5M96XKVm2e1txa+NrcQiSTqRa2OpEEMIKBZ1Q4ssFVmVXmFjhFHQ2rA k4K878o/PAl+BpeTDzxbQgaZqQau2zGMwqzLwIfu511QBQm1RletoW+N0xF6SQGyudbS umGRW/DKx76dhSEjbW2p64xRo0mrZfLqsPqmj4emRUVwOf8ZlPBuQd/xR5uXXCaeDhh9 GhSxIDejyi29chbwMHFlQBo5UP0AVar431/aLCQc5dT6HWaE/DJ32U/F5Vq0WyKsx7Ef N1cQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=b1X20J+A; 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 w25-20020aa7d299000000b0050bcc56b51esi2159730edq.283.2023.05.26.00.48.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 00:48:21 -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=b1X20J+A; 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 0341C3959E7B for ; Fri, 26 May 2023 07:41:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0341C3959E7B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685086896; bh=tMPotch9Hl1zZADiS8CtwSOGk0bpMpUzvW/5vgmgZGU=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=b1X20J+AWmV4bMmW/ycqQXTKgoJ9yG8jMnZ2ibR9oxeXAxw5BRCN8RlLotISssyJa 97q6AY4/HU5UAHB082RKwRtJEnV/FwQwL8LNEeI1vkb2BQy/cRsIBHnUYohXfUQn8b ebHM6H3maDtpq5DKn9t2PZlvY1nDKmUVZ8UMnUvw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by sourceware.org (Postfix) with ESMTPS id 106873856973 for ; Fri, 26 May 2023 07:36:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 106873856973 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3090d3e9c92so336774f8f.2 for ; Fri, 26 May 2023 00:36:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685086570; x=1687678570; 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=tMPotch9Hl1zZADiS8CtwSOGk0bpMpUzvW/5vgmgZGU=; b=DVuDAI9Nl3ZEMrhpIqD1qpAUwH5uMj08xbBTbh4pc5MN+s3Vl93tYYayGyFSfv05/u 5gxMLZO5sfKzFvH1KkbNjDp8KSFDqTUBG3EwdJOJSsks5Yow+ykwBs0j8hcjhkFKP69u 7cUyWbxIxm4/VrJ7L2AkpzCdlY+k8gfcU3rJksCxZdImuk+kxUyK46puDFsWZzL0eMHo H7po97IUaWX4N0Gv1domqNe0lKNB3W6PBpvh3xjkW/1/ADyMDy+mPATtZPdNmff+B6dZ +cn6LPxx3XAfY3WqEGQ4iAINWO7e7bLHCMZBgoD1PWTqGTRs2UajBb+quHM0kYI4jhT9 hQMw== X-Gm-Message-State: AC+VfDxO8QDWydmnhe/9wuU8kBOUXeLaHE3Zix+q+5Aqh0algWlZOPnN wnBrW0ztsaRtcPk2HBWQhnv0Fr6MtVOTISgI/V5oDg== X-Received: by 2002:a5d:564a:0:b0:309:3ddc:1c8d with SMTP id j10-20020a5d564a000000b003093ddc1c8dmr740904wrw.70.1685086569931; Fri, 26 May 2023 00:36:09 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:777b:eef4:6f79:f26f]) by smtp.gmail.com with ESMTPSA id b3-20020a5d5503000000b002ca864b807csm4281398wrv.0.2023.05.26.00.36.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 May 2023 00:36:09 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED] ada: Fix iteration over component items with pragmas Date: Fri, 26 May 2023 09:36:08 +0200 Message-Id: <20230526073608.2068573-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.6 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?1766942102546227976?= X-GMAIL-MSGID: =?utf-8?q?1766942102546227976?= From: Piotr Trojanek Component items in a record declaration might include pragmas, which must be ignored when detecting components with default expressions. More a code cleanup than a bugfix, as it only affects artificial corner cases. Found while fixing missing legality checks for variant component declarations. gcc/ada/ * sem_ch3.adb (Check_CPP_Type_Has_No_Defaults): Iterate with First_Non_Pragma and Next_Non_Pragma. * exp_dist.adb (Append_Record_Traversal): Likewise. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_dist.adb | 4 ++-- gcc/ada/sem_ch3.adb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gcc/ada/exp_dist.adb b/gcc/ada/exp_dist.adb index 8f62bef2c64..f025b5656c6 100644 --- a/gcc/ada/exp_dist.adb +++ b/gcc/ada/exp_dist.adb @@ -8304,7 +8304,7 @@ package body Exp_Dist is CI := Component_Items (Clist); VP := Variant_Part (Clist); - Item := First (CI); + Item := First_Non_Pragma (CI); while Present (Item) loop Def := Defining_Identifier (Item); @@ -8313,7 +8313,7 @@ package body Exp_Dist is (Stmts, Container, Counter, Rec, Def); end if; - Next (Item); + Next_Non_Pragma (Item); end loop; if Present (VP) then diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 9e32dea5c02..fb4f5badd4e 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -12312,7 +12312,7 @@ package body Sem_Ch3 is -- Check all components to ensure no default expressions if Present (Clist) then - Comp := First (Component_Items (Clist)); + Comp := First_Non_Pragma (Component_Items (Clist)); while Present (Comp) loop if Present (Expression (Comp)) then Error_Msg_N @@ -12320,7 +12320,7 @@ package body Sem_Ch3 is & "default expression", Expression (Comp)); end if; - Next (Comp); + Next_Non_Pragma (Comp); end loop; end if; end Check_CPP_Type_Has_No_Defaults;