sem_ch3.adb (Analyze_Full_Type_Declaration): If the declaration is a completion and...
authorEd Schonberg <schonberg@adacore.com>
Thu, 4 Aug 2011 09:11:43 +0000 (09:11 +0000)
committerArnaud Charlet <charlet@gcc.gnu.org>
Thu, 4 Aug 2011 09:11:43 +0000 (11:11 +0200)
2011-08-04  Ed Schonberg  <schonberg@adacore.com>

* sem_ch3.adb (Analyze_Full_Type_Declaration): If the declaration is a
completion and aspects are present, apply them to the entity for the
type which is currently the partial view, but which is the one that
will be frozen.
* sem_ch13.adb (Analyze_Aspect_Specifications): if the predicate
applies to a partial view, indicate that the full view has predicates
and delayed aspects.
(Replace_Type_Reference): Handle properly predicates that apply to the
full view of a private completion.

From-SVN: r177340

gcc/ada/ChangeLog
gcc/ada/sem_ch13.adb
gcc/ada/sem_ch3.adb

index 019f5a2..6ce0420 100644 (file)
@@ -1,3 +1,15 @@
+2011-08-04  Ed Schonberg  <schonberg@adacore.com>
+
+       * sem_ch3.adb (Analyze_Full_Type_Declaration): If the declaration is a
+       completion and aspects are present, apply them to the entity for the
+       type which is currently the partial view, but which is the one that
+       will be frozen.
+       * sem_ch13.adb (Analyze_Aspect_Specifications): if the predicate
+       applies to a partial view, indicate that the full view has predicates
+       and delayed aspects.
+       (Replace_Type_Reference): Handle properly predicates that apply to the
+       full view of a private completion.
+
 2011-08-04  Eric Botcazou  <ebotcazou@adacore.com>
 
        * layout.adb (Layout_Type): For composite types, do not set Esize.
index c3816cc..0423d61 100644 (file)
@@ -695,8 +695,8 @@ package body Sem_Ch13 is
       --  Insert pragmas (except Pre/Post/Invariant/Predicate) after this node
 
       --  The general processing involves building an attribute definition
-      --  clause or a pragma node that corresponds to the access type. Then
-      --  one of two things happens:
+      --  clause or a pragma node that corresponds to the aspect. Then one
+      --  of two things happens:
 
       --  If we are required to delay the evaluation of this aspect to the
       --  freeze point, we attach the corresponding pragma/attribute definition
@@ -1238,6 +1238,14 @@ package body Sem_Ch13 is
                   --  have a place to build the predicate function).
 
                   Set_Has_Predicates (E);
+
+                  if Is_Private_Type (E)
+                    and then Present (Full_View (E))
+                  then
+                     Set_Has_Predicates (Full_View (E));
+                     Set_Has_Delayed_Aspects (Full_View (E));
+                  end if;
+
                   Ensure_Freeze_Node (E);
                   Set_Is_Delayed_Aspect (Aspect);
                   Delay_Required := True;
@@ -4221,8 +4229,13 @@ package body Sem_Ch13 is
                Arg2 := Get_Pragma_Arg (Arg2);
 
                --  See if this predicate pragma is for the current type
+               --  or for its full view. A predicate on a private completion
+               --  is placed on the partial view beause this is the visible
+               --  entity that is frozen..
 
-               if Entity (Arg1) = Typ then
+               if Entity (Arg1) = Typ
+                 or else Full_View (Entity (Arg1)) = Typ
+               then
 
                   --  We have a match, this entry is for our subtype
 
index d31aea0..0586b71 100644 (file)
@@ -2500,8 +2500,16 @@ package body Sem_Ch3 is
       Set_Optimize_Alignment_Flags (Def_Id);
       Check_Eliminated (Def_Id);
 
+      --  If the declaration is a completion and aspects are present, apply
+      --  them to the entity for the type which is currently the partial
+      --  view, but which is the one that will be frozen.
+
       if Has_Aspects (N) then
-         Analyze_Aspect_Specifications (N, Def_Id);
+         if Prev /= Def_Id then
+            Analyze_Aspect_Specifications (N, Prev);
+         else
+            Analyze_Aspect_Specifications (N, Def_Id);
+         end if;
       end if;
    end Analyze_Full_Type_Declaration;