From: Ed Schonberg Date: Thu, 11 Jan 2018 08:51:47 +0000 (+0000) Subject: [Ada] Handling of pragma Predicate X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4d6000d73e1efaa2a97b7723a9bf94238d1705ed;p=gcc.git [Ada] Handling of pragma Predicate This patch fixes an omission in the processing of pragma Predicate, which should have the same semantics as the corresponding aspect, which is more commonly used. Executing gnatmake -q -gnata predicate predicate must yield: Even1 violated Even2 violated ---- with Text_IO; use Text_IO; procedure Predicate is begin begin declare subtype Even1 is Integer; pragma Predicate (Even1, Even1 mod 2 = 0); X1 : constant Even1 := 1; -- This should fail first begin null; end; exception when Others => Put_Line ("Even1 violated"); end; begin declare subtype Even2 is Integer with Predicate => Even2 mod 2 = 0; X2 : constant Even2 := 1; -- This should fail later, if reached begin null; end; exception when Others => Put_Line ("Even2 violated"); end; end; 2018-01-11 Ed Schonberg gcc/ada/ * sem_prag.adb (Analyze_Pragma, case Predicate): Indicate that the type has a delayed aspect which must be processed at the point the type is frozen. This mimics what is done when the predicate is provided by a source aspect. From-SVN: r256495 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index cb7014e3e28..a938ab2fbcc 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,10 @@ +2018-01-11 Ed Schonberg + + * sem_prag.adb (Analyze_Pragma, case Predicate): Indicate that the type + has a delayed aspect which must be processed at the point the type is + frozen. This mimics what is done when the predicate is provided by a + source aspect. + 2018-01-11 Doug Rupp * init.c (vxworks): Add macro checks for __aarch64__. diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 4f55db145e7..ba629baf963 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -20244,6 +20244,13 @@ package body Sem_Prag is -- general Assertion_Policy pragma) to preserve existing warnings. Set_Has_Predicates (Typ); + + -- Indicate that the pragma must be processed at the point the + -- type is frozen, as is done for the corresponding aspect. + + Set_Has_Delayed_Aspects (Typ); + Set_Has_Delayed_Freeze (Typ); + Set_Predicates_Ignored (Typ, Present (Check_Policy_List) and then