aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Schonberg <schonberg@adacore.com>2018-01-11 08:51:47 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2018-01-11 08:51:47 +0000
commit4d6000d73e1efaa2a97b7723a9bf94238d1705ed (patch)
tree8402402b378eb51933e581b190f708bfa108a6bd
parent19fb043958578d5802565162d90ccea952dd0504 (diff)
downloadgcc-4d6000d73e1efaa2a97b7723a9bf94238d1705ed.zip
gcc-4d6000d73e1efaa2a97b7723a9bf94238d1705ed.tar.gz
gcc-4d6000d73e1efaa2a97b7723a9bf94238d1705ed.tar.bz2
[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 <schonberg@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. From-SVN: r256495
-rw-r--r--gcc/ada/ChangeLog7
-rw-r--r--gcc/ada/sem_prag.adb7
2 files changed, 14 insertions, 0 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index cb7014e..a938ab2 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,10 @@
+2018-01-11 Ed Schonberg <schonberg@adacore.com>
+
+ * 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 <rupp@adacore.com>
* init.c (vxworks): Add macro checks for __aarch64__.
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index 4f55db1..ba629ba 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