public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Marc Poulhi?s <dkm@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-1101] ada: Spurious errors on class-wide preconditions of private types Date: Tue, 23 May 2023 08:06:45 +0000 (GMT) [thread overview] Message-ID: <20230523080645.B9DA63858433@sourceware.org> (raw) https://gcc.gnu.org/g:90e1445904179706e50c90c6553e127dbb2c43e8 commit r14-1101-g90e1445904179706e50c90c6553e127dbb2c43e8 Author: Javier Miranda <miranda@adacore.com> Date: Fri Feb 17 18:57:07 2023 +0000 ada: Spurious errors on class-wide preconditions of private types 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. Diff: --- 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;
reply other threads:[~2023-05-23 8:06 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230523080645.B9DA63858433@sourceware.org \ --to=dkm@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).