[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Mon, 21 Nov 2011 11:26:14 +0000 (12:26 +0100)
committerArnaud Charlet <charlet@gcc.gnu.org>
Mon, 21 Nov 2011 11:26:14 +0000 (12:26 +0100)
2011-11-21  Robert Dewar  <dewar@adacore.com>

* exp_ch6.adb: Minor reformatting.

2011-11-21  Ed Schonberg  <schonberg@adacore.com>

* sem_ch12.adb (Check_Formal_Package_Instance): If a formal
subprogram of the formal package is covered by an others
association with a box initialization, no check is needed
against the actual in the instantiation of the formal package.

2011-11-21  Robert Dewar  <dewar@adacore.com>

* sem_elab.adb (Check_Internal_Call_Continue): Suppress junk
elab warning from within precondition/postcondition etc.

From-SVN: r181561

gcc/ada/exp_ch6.adb
gcc/ada/sem_ch12.adb
gcc/ada/sem_elab.adb

index b68fb8af909c042069962201ba0a8ddf879f11d2..6673328acaf560c814444f8081e5a4ebf87dc92a 100644 (file)
@@ -8532,8 +8532,8 @@ package body Exp_Ch6 is
          return False;
 
       --  Handle a corner case, a cross-dialect subp renaming. For example,
-      --  an Ada 2012 renaming of an Ada 05 subprogram. This can occur when a
-      --  non-Ada 2012 unit references predefined run-time units.
+      --  an Ada 2012 renaming of an Ada 2005 subprogram. This can occur when
+      --  an Ada 2005 (or earlier) unit references predefined run-time units.
 
       elsif Present (Alias (Func_Id)) then
 
index e51b8029803bfbadffddcc2db05f6f57eb7f29fe..2a431f8635e125f4c411974b252652111cb26ff4 100644 (file)
@@ -5076,6 +5076,18 @@ package body Sem_Ch12 is
             then
                null;
 
+            --  If the formal package has an "others"  box association that
+            --  covers this formal, there is no need for a check either.
+
+            elsif Nkind (Unit_Declaration_Node (E2)) in
+                    N_Formal_Subprogram_Declaration
+              and then Box_Present (Unit_Declaration_Node (E2))
+            then
+               null;
+
+            --  Otherwise the actual in the formal and the actual in the
+            --  instantiation of the formal must match, up to renamings.
+
             else
                Check_Mismatch
                  (Ekind (E2) /= Ekind (E1) or else (Alias (E1)) /= Alias (E2));
@@ -12383,9 +12395,11 @@ package body Sem_Ch12 is
       procedure Reset_Entity (N : Node_Id) is
 
          procedure Set_Global_Type (N : Node_Id; N2 : Node_Id);
-         --  If the type of N2 is global to the generic unit. Save the type in
-         --  the generic node.
-         --  What does this comment mean???
+         --  If the type of N2 is global to the generic unit, save the type in
+         --  the generic node. Just as we perform name capture for explicit
+         --  references within the generic, we must capture the global types
+         --  of local entities because they may participate in resolution in
+         --  the instance.
 
          function Top_Ancestor (E : Entity_Id) return Entity_Id;
          --  Find the ultimate ancestor of the current unit. If it is not a
index 5df43afc43eb11c0b99176e9f2564204cc137d15..d51dae91b33856da85349e1847a3acfb463fa270 100644 (file)
@@ -2130,7 +2130,32 @@ package body Sem_Elab is
       end if;
 
       --  Here is the case of calling a subprogram where the body has not yet
-      --  been encountered, a warning message is needed.
+      --  been encountered. A warning message is needed, except if this is the
+      --  case of appearing within an aspect specification that results in
+      --  a check call, we do not really have such a situation, so no warning
+      --  is needed (e.g., the case of a precondition, where the call appears
+      --  textually before the body, but in actual fact is moved to the
+      --  appropriate subprogram body and so does not need a check).
+
+      declare
+         P : Node_Id;
+      begin
+         P := Parent (N);
+         loop
+            if Nkind (P) in N_Subexpr then
+               P := Parent (P);
+            elsif Nkind (P) = N_If_Statement
+              and then Nkind (Original_Node (P)) = N_Pragma
+              and then Present (Corresponding_Aspect (Original_Node (P)))
+            then
+               return;
+            else
+               exit;
+            end if;
+         end loop;
+      end;
+
+      --  Not that special case, warning and dynamic check is required
 
       --  If we have nothing in the call stack, then this is at the outer
       --  level, and the ABE is bound to occur.