This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] In a generic use Presanalyze_Spec_Expression on Predicates

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.

Tested on x86_64-pc-linux-gnu, committed on trunk

2019-09-17  Ed Schonberg  <>


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


	* gnat.dg/predicate13.adb, gnat.dg/ New
--- gcc/ada/sem_ch13.adb
+++ gcc/ada/sem_ch13.adb
@@ -9383,7 +9383,7 @@ package body Sem_Ch13 is
               or else A_Id = Aspect_Priority
                Push_Type (Ent);
-               Preanalyze (Freeze_Expr);
+               Preanalyze_Spec_Expression (Freeze_Expr, T);
                Pop_Type (Ent);
                Preanalyze (Freeze_Expr);

--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/predicate13.adb
@@ -0,0 +1,3 @@
+package body Predicate13 is
+    procedure Dummy is null;
+end Predicate13;
\ No newline at end of file

--- /dev/null
new file mode 100644
+++ gcc/testsuite/gnat.dg/
@@ -0,0 +1,23 @@
+--  { dg-do compile }
+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;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]