From patchwork Tue May 23 08:08:24 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: 97864 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1976558vqo; Tue, 23 May 2023 01:17:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7vTlhBnO5lkSwEWCtMvASA142t0x0MSR1DohtZavbL3qMjzIThL4yvSWA2Wb8gm40jZEVo X-Received: by 2002:a17:906:dc94:b0:96a:47d7:8b52 with SMTP id cs20-20020a170906dc9400b0096a47d78b52mr12335133ejc.77.1684829867670; Tue, 23 May 2023 01:17:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684829867; cv=none; d=google.com; s=arc-20160816; b=wrgBtCRfmDTdcQeYnMqp4cuhlwzSJ+uBIrVRWzIX5wCQHsq77gDhq5y/2UpDLfpa0w RiEc/0rM8tA0xuxDeNim3oI1vEPtTC2YeRqGwa/+HPaumsoiWn2wu/NTljw5Y6VD4/xk Q+Ym00uZswvSQyGYqTfU26M7LKPRodcyB7Qd4uzLGBt6RaBNSW4NFxWb4DnzUroncN9H EasA+E/MyYAdPTtf+Dya6KgF60Kt5tBmzxSwdH9tdoq1cGkpi9MIzPRQXwQF+fFze2Yp MoCeVY440H8DC7egtK6Ppn+EkFcslZ8PtkidaaRJQp4tOwfKrzMrsBCk/VliapOLqS/D s0Gw== 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=uwHW19eitu9C76klJvetEgmWnPPT7gSp/fLTRE15Q0A=; b=zbDRW2HkNb+eulBPPAtt/7lnQXgM9a+YwwefJWqL/4Nm+GUeba52r9Q7npiK+ZKUfJ Sa3+UabpCr1Bz7XQskk+AFDBGCdFpAknaOXTznd4Jm1Er02Vwt6RTfvT73O7pasymqFP KZh/HlD4YOFOcHQHeG9SzMAAjOvQ6vXItmmb8erqnhvoUQiWN+C6HFzSMimuBAWciD2Q QDeHy0e5KV0iN6QbpmOHmS5KhjB8SRhCWiOFcgABz/5CTPx385di6l+2X4z20l1BDNyB 2Vp/BMyKO9ixzQN+XHHKlFu65PUma9IGMWVptNT0/V3OoIyNG/xAhm6VsSBMRqcrl2Fk B1fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=UQ5uxDpK; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id 27-20020a170906015b00b00965a1d85cf1si110972ejh.890.2023.05.23.01.17.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 May 2023 01:17:47 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=UQ5uxDpK; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 7D2B03949F28 for ; Tue, 23 May 2023 08:12:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7D2B03949F28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684829541; bh=uwHW19eitu9C76klJvetEgmWnPPT7gSp/fLTRE15Q0A=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=UQ5uxDpK56DKzRZGM82VmRgiDO3opmS7NRVhQ6XCFYy/vbNEEUP+zDzWGQcGircGv 7y/B/iPQ3W8vNhsYKfICmLdKYAunHt4AhoYZpCtcCDzGvp9zGxmlDjvMntHjmqHwiF LvDvBVeK0pfqtNHPCfmW3Pk9Q58NuFmr/KLYkiO4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by sourceware.org (Postfix) with ESMTPS id 778123882018 for ; Tue, 23 May 2023 08:08:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 778123882018 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-3078aa0b152so4590857f8f.3 for ; Tue, 23 May 2023 01:08:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684829305; x=1687421305; 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=uwHW19eitu9C76klJvetEgmWnPPT7gSp/fLTRE15Q0A=; b=OPObcY9teP0sOht4YVG67GGXHcqwVMII4WjGNg4ntQ4krFbqZTPsQ5bFG4HC5HWJpw HKPwkbKc+J4Cg5wJiC0jhXdbZ3euFivjB+RCAqpS+9+FBPR0izeGgBVNvPSMzB2ja61u armV9lFPuVx64v3fWDAQPbzMHuHuQZ/kN+lhF0DeF7zZGgtm2fcAICN4njBfqsFo5aKQ 6TBLnZLorH5BtvE4LNRi/aO71U9LZlxuHXciiwbf85Okc2O2t5xYqbkfxlRyPVRrTS4I 6gXGosY3ePrhf+2oC7dxp0vfX+Wv47V2o0Um7G+chZywow/YzL5vKcHT3w5kvJleYGVL wdbQ== X-Gm-Message-State: AC+VfDzs6l+o2T1PYpve1x5nBktYjq1aevfNf2C+tZvqeW9NL0E7QEka 3W6Jsd3sq/Kb4wlr5Z0tIaqHvfWSufzSwLckKS2NnA== X-Received: by 2002:a5d:58d4:0:b0:309:40ba:1eb0 with SMTP id o20-20020a5d58d4000000b0030940ba1eb0mr9001854wrf.40.1684829305308; Tue, 23 May 2023 01:08:25 -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 n1-20020a05600c294100b003ee74c25f12sm14068162wmd.35.2023.05.23.01.08.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 May 2023 01:08:24 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Javier Miranda Subject: [COMMITTED] ada: Spurious errors on class-wide preconditions of private types Date: Tue, 23 May 2023 10:08:24 +0200 Message-Id: <20230523080824.1873672-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?1766672163288333164?= X-GMAIL-MSGID: =?utf-8?q?1766672163288333164?= From: Javier Miranda The compiler reports spurious errors processing the class-wide preconditions of a dispatching primitive of a private type T, when the class-wide precondition invokes another dispatching primitive of T that has the same name as a record component of T. gcc/ada/ * sem_prag.adb (Analyze_Pre_Post_Condition_In_Decl_Part): Remove call to preanalyze class-wide conditions since here it is too early; they must be preanalyzed when full views of private types have been analyzed. * sem_ch7.adb (Analyze_Package_Specification): Preanalyze class-wide conditions of dispatching primitives defined in nested packages. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch7.adb | 14 ++++++++++++++ gcc/ada/sem_prag.adb | 14 -------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/gcc/ada/sem_ch7.adb b/gcc/ada/sem_ch7.adb index 2610a7bba4d..aed09f30934 100644 --- a/gcc/ada/sem_ch7.adb +++ b/gcc/ada/sem_ch7.adb @@ -1936,6 +1936,20 @@ package body Sem_Ch7 is end; end if; + -- Preanalyze class-wide conditions of dispatching primitives defined + -- in nested packages. For library packages, class-wide pre- and + -- postconditions are preanalyzed when the primitives are frozen + -- (see Merge_Class_Conditions); for nested packages, the end of the + -- package does not cause freezing (and hence they must be analyzed + -- now to ensure the correct visibility of referenced entities). + + if not Is_Compilation_Unit (Id) + and then Is_Dispatching_Operation (E) + and then Present (Contract (E)) + then + Preanalyze_Class_Conditions (E); + end if; + Next_Entity (E); end loop; diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 234b02d7b72..ca55a6f8290 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -26269,20 +26269,6 @@ package body Sem_Prag is Check_Postcondition_Use_In_Inlined_Subprogram (N, Spec_Id); Set_Is_Analyzed_Pragma (N); - -- If the subprogram is frozen then its class-wide pre- and post- - -- conditions have been preanalyzed (see Merge_Class_Conditions); - -- otherwise they must be preanalyzed now to ensure the correct - -- visibility of their referenced entities. This scenario occurs - -- when the subprogram is defined in a nested package (since the - -- end of the package does not cause freezing). - - if Class_Present (N) - and then Is_Dispatching_Operation (Spec_Id) - and then not Is_Frozen (Spec_Id) - then - Preanalyze_Class_Conditions (Spec_Id); - end if; - Restore_Ghost_Region (Saved_GM, Saved_IGR); end Analyze_Pre_Post_Condition_In_Decl_Part;