From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 DD1783858415 for ; Tue, 13 Jun 2023 07:37:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DD1783858415 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3f8c74af64fso3524575e9.1 for ; Tue, 13 Jun 2023 00:37:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1686641868; x=1689233868; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=yYZaseusJvDi/BX7v1cTWXmYeAPVhWG15hM7/ivfBoQ=; b=XO7HsrdRkmBuYz2zkwn2d4ewBAgtfMSn1sdIgSN3SvVHPSzYDdVucqzpRdPoIIECJZ zIObtQPjQj3O0hDVIBNUcQr3Y/EWQ8xqCsuK908i0gr3aFGE5e55fX3gpKM03+6Y/6c7 sNzfLlg82+Z+xbKLDyYOcWMSwg9741amrPWy/2rViynJgJEDkMboPDzQLu7jgVFczks2 +dI3DTISV7LMCn50lRjV+Cr4pp/NGY7ZuWbe2AjcSbpU6nfYig+sw8JBSDZkh2aLAbIG IzA04oznTA8K3SwqieDC9v9mugkjuWX/EQcIhzrGs9+pVhkS2l5dhKhIfDohJ1PBmABK 31ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686641868; x=1689233868; 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=yYZaseusJvDi/BX7v1cTWXmYeAPVhWG15hM7/ivfBoQ=; b=JyBuasqTKIAVoXvmr96jGMbyuvKuku3XSzNp3UK++rDxZO/YgUbzTLnhadpds4gzYd ixBhgvGenZWftkiPmqxdK7toS0StyZ4fDVDmYioSRD44RdCWUSidnF0SpPTw0QH75b9e ir8e1uzWBzornU3HhaT+pzgnOs7Hgd4NAzrBbXNEJIF3XQSsIdaQP403oR8dzgJKRyOv jbPQKLVflxWk0EVYB+TGeu8W2IXqjJBQ3o7vhmBj09p7QRsci6i/5u0Xa7YlJcXhQv5/ WjmlLmtPEuHTg+fIPhPUVd6pKWW+TBQDHZ/LlCwyUED872Umm2LDo0hkhxRgCIjQfZjT zmaA== X-Gm-Message-State: AC+VfDx5qiNmvVU6keKATWw1qWf5+pd8ER/tWo4tBiS83nWo160iLPcD JN6g3D6fUS3H0DTR+u4GPF/A8OkRBooGP2rhmjjkiA== X-Google-Smtp-Source: ACHHUZ60AThwp8aVWJ7mVrfubPyo2Zcz0mtEZKoUthstHj8ph9tAvtOKH0c5xXlS65p5sjI4sokt0Q== X-Received: by 2002:a7b:c84c:0:b0:3f7:33cf:707b with SMTP id c12-20020a7bc84c000000b003f733cf707bmr8290250wml.1.1686641868703; Tue, 13 Jun 2023 00:37:48 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:bfa8:5d29:40e5:cc66]) by smtp.gmail.com with ESMTPSA id e13-20020a05600c218d00b003f709a7e46bsm13404118wme.46.2023.06.13.00.37.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jun 2023 00:37:48 -0700 (PDT) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED] ada: Cleanup finding of locally handled exception handlers Date: Tue, 13 Jun 2023 09:37:46 +0200 Message-Id: <20230613073746.239122-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.7 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 List-Id: From: Piotr Trojanek Code cleanup related to handling exceptions in GNATprove; semantics is unaffected. gcc/ada/ * exp_ch11.adb (Find_Local_Handler): Replace guard against other constructs appearing in the list of exception handlers with iteration using First_Non_Pragma/Next_Non_Pragma. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_ch11.adb | 68 +++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/gcc/ada/exp_ch11.adb b/gcc/ada/exp_ch11.adb index da02eb9bfb2..db85c7efa6e 100644 --- a/gcc/ada/exp_ch11.adb +++ b/gcc/ada/exp_ch11.adb @@ -1819,62 +1819,60 @@ package body Exp_Ch11 is | SSE.Actions_To_Be_Wrapped (After) | SSE.Actions_To_Be_Wrapped (Cleanup) then - -- Loop through exception handlers + -- Loop through exception handlers and guard against pragmas + -- appearing among them. - H := First (Exception_Handlers (P)); + H := First_Non_Pragma (Exception_Handlers (P)); while Present (H) loop -- Guard against other constructs appearing in the list of -- exception handlers. - if Nkind (H) = N_Exception_Handler then + -- Loop through choices in one handler - -- Loop through choices in one handler + C := First (Exception_Choices (H)); + while Present (C) loop - C := First (Exception_Choices (H)); - while Present (C) loop + -- Deal with others case - -- Deal with others case + if Nkind (C) = N_Others_Choice then - if Nkind (C) = N_Others_Choice then + -- Matching others handler, but we need to ensure there + -- is no choice parameter. If there is, then we don't + -- have a local handler after all (since we do not allow + -- choice parameters for local handlers). - -- Matching others handler, but we need to ensure - -- there is no choice parameter. If there is, then we - -- don't have a local handler after all (since we do - -- not allow choice parameters for local handlers). - - if No (Choice_Parameter (H)) then - return H; - else - return Empty; - end if; + if No (Choice_Parameter (H)) then + return H; + else + return Empty; + end if; - -- If not others must be entity name + -- If not others must be entity name - else - pragma Assert (Is_Entity_Name (C)); - pragma Assert (Present (Entity (C))); + else + pragma Assert (Is_Entity_Name (C)); + pragma Assert (Present (Entity (C))); - -- Get exception being handled, dealing with renaming + -- Get exception being handled, dealing with renaming - EHandle := Get_Renamed_Entity (Entity (C)); + EHandle := Get_Renamed_Entity (Entity (C)); - -- If match, then check choice parameter + -- If match, then check choice parameter - if ERaise = EHandle then - if No (Choice_Parameter (H)) then - return H; - else - return Empty; - end if; + if ERaise = EHandle then + if No (Choice_Parameter (H)) then + return H; + else + return Empty; end if; end if; + end if; - Next (C); - end loop; - end if; + Next (C); + end loop; - Next (H); + Next_Non_Pragma (H); end loop; end if; -- 2.40.0