public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-5022] [Ada] Errors on globals in expressions of predicate aspects in generic bodies Date: Tue, 9 Nov 2021 09:46:00 +0000 (GMT) [thread overview] Message-ID: <20211109094600.29778385842E@sourceware.org> (raw) https://gcc.gnu.org/g:64cb8ebef32c44ab7cab6021942df0b3d08a5fe5 commit r12-5022-g64cb8ebef32c44ab7cab6021942df0b3d08a5fe5 Author: Gary Dismukes <dismukes@adacore.com> Date: Mon Oct 25 20:45:50 2021 -0400 [Ada] Errors on globals in expressions of predicate aspects in generic bodies gcc/ada/ * sem_ch13.adb (Freeze_Entity_Checks): Analyze the expression of a pragma Predicate associated with an aspect at the freeze point of the type, to ensure that references to globals get saved when the aspect occurs within a generic body. Also, add Aspect_Static_Predicate to the choices of the membership test of the enclosing guard. Diff: --- gcc/ada/sem_ch13.adb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 6059cee0022..be9b84e5ec7 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -13162,6 +13162,7 @@ package body Sem_Ch13 is if Get_Aspect_Id (Ritem) in Aspect_CPU | Aspect_Dynamic_Predicate | Aspect_Predicate + | Aspect_Static_Predicate | Aspect_Priority then -- Retrieve the visibility to components and discriminants @@ -13169,6 +13170,34 @@ package body Sem_Ch13 is Push_Type (E); Check_Aspect_At_Freeze_Point (Ritem); + + -- In the case of predicate aspects, there will be + -- a corresponding Predicate pragma associated with + -- the aspect, and the expression of the pragma also + -- needs to be analyzed at this point, to ensure that + -- Save_Global_References will capture global refs in + -- expressions that occur in generic bodies, for proper + -- later resolution of the pragma in instantiations. + + if Is_Type (E) + and then Inside_A_Generic + and then Has_Predicates (E) + and then Present (Aspect_Rep_Item (Ritem)) + then + declare + Pragma_Args : constant List_Id := + Pragma_Argument_Associations + (Aspect_Rep_Item (Ritem)); + Pragma_Expr : constant Node_Id := + Expression (Next (First (Pragma_Args))); + begin + if Present (Pragma_Expr) then + Analyze_And_Resolve + (Pragma_Expr, Standard_Boolean); + end if; + end; + end if; + Pop_Type (E); else
reply other threads:[~2021-11-09 9:46 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=20211109094600.29778385842E@sourceware.org \ --to=pmderodat@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).