]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] In a generic use Presanalyze_Spec_Expression on Predicates
authorEd Schonberg <schonberg@adacore.com>
Tue, 17 Sep 2019 08:00:07 +0000 (08:00 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Tue, 17 Sep 2019 08:00:07 +0000 (08:00 +0000)
When verifying that the meaning of an aspect has not changed between the
freeze point of the entity and the end of the declarations, we analkyze
a copy of the expression to verify its conformance to previous analysis.
If the expression contains overloaded references, these have to be
resolved, which is not done if the expression is only preanalyzed.  This
applies in particular to expressions in predicates.

2019-09-17  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

* sem_ch13.adb (Check_Aspect_At_End_Of_Declarations): In a
generic context, for a Predicate aspect, use
Preanalyze_Spec_Expression to verify conformance.

gcc/testsuite/

* gnat.dg/predicate13.adb, gnat.dg/predicate13.ads: New
testcase.

From-SVN: r275778

gcc/ada/ChangeLog
gcc/ada/sem_ch13.adb
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/predicate13.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/predicate13.ads [new file with mode: 0644]

index 1d728fe17a7464031452e8e9e807316ffb473f3f..94877b24ea138fd545274c988598eb9895f3f12b 100644 (file)
@@ -1,3 +1,9 @@
+2019-09-17  Ed Schonberg  <schonberg@adacore.com>
+
+       * sem_ch13.adb (Check_Aspect_At_End_Of_Declarations): In a
+       generic context, for a Predicate aspect, use
+       Preanalyze_Spec_Expression to verify conformance.
+
 2019-09-17  Javier Miranda  <miranda@adacore.com>
 
        * sem_ch3.adb (Constrain_Corresponding_Record): Propagate
index 2538c1da982fad8e49dae4680a9283a315a42830..ef9f965a564b3d5cce5f5c899963c35ebfa5ba21 100644 (file)
@@ -9383,7 +9383,7 @@ package body Sem_Ch13 is
               or else A_Id = Aspect_Priority
             then
                Push_Type (Ent);
-               Preanalyze (Freeze_Expr);
+               Preanalyze_Spec_Expression (Freeze_Expr, T);
                Pop_Type (Ent);
             else
                Preanalyze (Freeze_Expr);
index 30c75dfea8f78e2af206132ca89467048e50d3e3..d5b3e5a659042475935e0f4d1c696cde265ae04f 100644 (file)
@@ -1,3 +1,8 @@
+2019-09-17  Ed Schonberg  <schonberg@adacore.com>
+
+       * gnat.dg/predicate13.adb, gnat.dg/predicate13.ads: New
+       testcase.
+
 2019-09-17  Javier Miranda  <miranda@adacore.com>
 
        * gnat.dg/limited4.adb: New testcase.
diff --git a/gcc/testsuite/gnat.dg/predicate13.adb b/gcc/testsuite/gnat.dg/predicate13.adb
new file mode 100644 (file)
index 0000000..24b6918
--- /dev/null
@@ -0,0 +1,3 @@
+package body Predicate13 is
+    procedure Dummy is null;
+end Predicate13;
\ No newline at end of file
diff --git a/gcc/testsuite/gnat.dg/predicate13.ads b/gcc/testsuite/gnat.dg/predicate13.ads
new file mode 100644 (file)
index 0000000..2e19d49
--- /dev/null
@@ -0,0 +1,23 @@
+--  { dg-do compile }
+generic
+package Predicate13 is
+
+    function Valid return Boolean is
+    (True);
+
+    function Foo return Boolean is
+    (True);
+
+    type State_Type is (Valid, Invalid);
+    type Context_Type is private;
+
+    private
+
+    type Context_Type is
+    record
+    State : State_Type;
+    end record  with Dynamic_Predicate => (State = Valid);
+
+    procedure Dummy;
+
+end Predicate13;