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: 97871 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1978325vqo; Tue, 23 May 2023 01:22:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7rjL4FUTViUpPrVbKv6ESePDnmUxDv9+BISbpIbTOG8/QlV+r/Ve9pUIgpNSrEYiSC4S0R X-Received: by 2002:a17:906:4d8f:b0:94f:3bf7:dacf with SMTP id s15-20020a1709064d8f00b0094f3bf7dacfmr12419658eju.71.1684830127114; Tue, 23 May 2023 01:22:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684830127; cv=none; d=google.com; s=arc-20160816; b=LeyUoSP+2ogZJ76lnAFcEMKPD8hOU3juIOFkrgFI4FItf/bVTtKind/IITcTS0FSm/ 7SX1vH71XFazRJGnQvyKmbV7U6lcmRKzhX6fHCPaKxgGDcP9WZb1HgSLxgWdoufJfxAP gWIUQAwNS0tjxAqyAYS39AkbGSoeTmi4SyMZ/G+bdyVWNz5/lmoqRXLlT+XTwjUlqMfh TzQz9CCGeXFOy8dkb3gOzCotYRtllRDcmqDAqLRyB06o37kcvNuLPVR4+c75nWeqNKbK YD8qeK/hQOUqcGvZbX1eDvSHbyiKBXC8p1cdUV+FFEHCJKnA8eWxdBXYRnR6vFhEe7WI Y1gQ== 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=kPjMzp0B5yHzjlmrhOWxCEAkpNxoCpco1C212lRA2Zc=; b=qKhR96BcvNvZfG22QYwVFONcrDdn28+PYgoO9Aq7J2YvpJuit/FNz0c6ooUHSoMGyE H6zn0TH7VDmnK4NEqo9HcPzIp9Q1SZDxlcxDk0RocybyT26V71yKEeVA/yeupvqn0Yxt M9TJiWvDgIEk6Y3HlKO5i2MxTqV36V+jgFuTTQQDINj8ABZ4Ki6M6IKj5wv0dCcewHz8 Jqqu0lVz3gqmH2zrgwyQ1dpNcEr6BA3JwH7clYox99IvJg47AwgQdpYCvXVMpbT77Acq By6tB3OgGrqYtH5OD3afV1mEZZX67ID5ILDbmQPTFbglNvDv2Ef3TmWhttDFJBO3d5aF kBfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=iwU9Ohwx; 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 qo5-20020a170907874500b0096621c999c5si5740536ejc.288.2023.05.23.01.22.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 May 2023 01:22:07 -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=iwU9Ohwx; 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 74272395B453 for ; Tue, 23 May 2023 08:14:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 74272395B453 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684829653; bh=kPjMzp0B5yHzjlmrhOWxCEAkpNxoCpco1C212lRA2Zc=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=iwU9OhwxR4YNi/bbwnkf/RlJMV22vk4zc0WW3L2WMD2fae6uDy6YSu25c3BdzDsou ghecmkyUuj7GzxQfbxhdDyfROSoIo87WuxVdRg5LCRt17K3mX8KQwyBzCm6enkTtjv MtmTyIa0aZYi6jdm4nDDC9tmB88a8HAiz0hAco4I= 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-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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766672434958837388?= X-GMAIL-MSGID: =?utf-8?q?1766672434958837388?= 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;