From patchwork Tue May 23 08:09:15 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: 1784954 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=yQIqAeBv; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QQRsm6bDBz2020 for ; Tue, 23 May 2023 18:13:48 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E8D6A3959E54 for ; Tue, 23 May 2023 08:13:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E8D6A3959E54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684829626; bh=kPjMzp0B5yHzjlmrhOWxCEAkpNxoCpco1C212lRA2Zc=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=yQIqAeBv92CexYfV4OJH4KOx8SpJxTbB1LdCwiCDpKvhsEn95btiWhyE4c8M6lknJ sh5bxKK8j1CUfxCqC1U++nVnzhj8ZCHXs8DHZIsPboIc65+J7hWT4+ru/awug1GiRZ D548IVuUDbLazCOmFO0a22eMw57VGo+5Sy3WBlLQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by sourceware.org (Postfix) with ESMTPS id C7ECD385355E for ; Tue, 23 May 2023 08:09:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C7ECD385355E Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3f42d937d2eso44249055e9.2 for ; Tue, 23 May 2023 01:09:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684829356; x=1687421356; 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=kPjMzp0B5yHzjlmrhOWxCEAkpNxoCpco1C212lRA2Zc=; b=AYlvkvGXaW0NAHt0ZoiHy3VOLB+Au1vWJxxooBqz/lPoZzLnZFXFW43pU42E3SEGRS qnWljNLxbERRg/vUEqrUWgJbIUFRFHrZPbgLLaMHFgV1C7nceH+yrHgUKfpJ3/l4IqDL QKhfMvsNn2uMQJqSrysaHPckLfX6aUzCHZW/e+Z2w/l/tBm+dsVyzo4BGLZeT7tMDw8w NSwGIjXe+RVMeu1pPDQH64RvDCP6O/oQfHPo3beZhgIkg7nA1Lb3mVKnO7/Uv84ef1df +tdYKI0KlcFzv9qByymmfEASLD3hfmQjvi0/i/KHlAmvYbDvpCMe6R99tk+ydAhsLJxF X6hQ== X-Gm-Message-State: AC+VfDzzzjuq96BrAqY9C9haFcdiEt9j80Z09PNpbKPP7QNTsNDGs7ik CkZDO5v/UzM1sjm0tBGSLSIiCjpcQ1NsGEbFxvlawg== X-Google-Smtp-Source: ACHHUZ4XSmkhASkgECBYDTSR+zH+tdVZN/y/WRryYlvs2bJ7+AaWBqFtcNfytycFGQYlLZLZwrRiTg== X-Received: by 2002:a7b:c5d4:0:b0:3f6:ae3:5948 with SMTP id n20-20020a7bc5d4000000b003f60ae35948mr1008743wmk.33.1684829356582; Tue, 23 May 2023 01:09:16 -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 e19-20020a05600c219300b003f50876905dsm10928108wme.6.2023.05.23.01.09.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 May 2023 01:09:16 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED] ada: Cleanup inconsistent iteration over exception handlers Date: Tue, 23 May 2023 10:09:15 +0200 Message-Id: <20230523080915.1874792-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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" From: Piotr Trojanek When detecting duplicate choices in exception handlers we had inconsistent pairs of First/Next_Non_Pragma and First_Non_Pragma/Next. This was harmless, because exception choices don't allow pragmas at all, e.g.: when Program_Error | Constraint_Error | ...; -- pragma not allowed and exception handlers only allow pragmas to appear as the first item on the list, e.g.: exception pragma Inspection_Point; -- first item on the list of handlers when Program_Error => pragma Inspection_Point; -- last item on the list of statements when Constraint_Error => ... However, it still seems cleaner to have consistent pairs of First/Next and First_Non_Pragma/Next_Non_Pragma. gcc/ada/ * sem_ch11.adb (Check_Duplication): Fix inconsistent iteration. (Others_Present): Iterate over handlers using First_Non_Pragma and Next_Non_Pragma just like in Check_Duplication. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch11.adb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/gcc/ada/sem_ch11.adb b/gcc/ada/sem_ch11.adb index 6d519ebdd41..5471111d682 100644 --- a/gcc/ada/sem_ch11.adb +++ b/gcc/ada/sem_ch11.adb @@ -136,10 +136,10 @@ package body Sem_Ch11 is end if; end if; - Next_Non_Pragma (Id1); + Next (Id1); end loop; - Next (Handler); + Next_Non_Pragma (Handler); end loop; end Check_Duplication; @@ -151,15 +151,13 @@ package body Sem_Ch11 is H : Node_Id; begin - H := First (L); + H := First_Non_Pragma (L); while Present (H) loop - if Nkind (H) /= N_Pragma - and then Nkind (First (Exception_Choices (H))) = N_Others_Choice - then + if Nkind (First (Exception_Choices (H))) = N_Others_Choice then return True; end if; - Next (H); + Next_Non_Pragma (H); end loop; return False;