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;
Tested on x86_64-pc-linux-gnu, committed on trunk
2018-01-11 Ed Schonberg <schonb...@adacore.com>
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.
--- gcc/ada/sem_prag.adb
+++ 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