restrict.adb (Update_Restrictions): For restrictions with a maximum parameter (e.g.
authorEd Schonberg <schonberg@adacore.com>
Fri, 1 Aug 2014 14:46:11 +0000 (14:46 +0000)
committerArnaud Charlet <charlet@gcc.gnu.org>
Fri, 1 Aug 2014 14:46:11 +0000 (16:46 +0200)
2014-08-01  Ed Schonberg  <schonberg@adacore.com>

* restrict.adb (Update_Restrictions): For restrictions with a
maximum parameter (e.g. number of protected entries in Ravenscar)
do not compute the maximum of the violation over several objects,
because the restriction is per-object.
(Check_Restriction): After possible message, reset the value
of of a checked max_parameter restriction to zero, to prevent
cascaded errors.
* sem_ch3.adb (Build_Derived_Private_Type): Use base of parent
(sub)type to determine whether derived type should be on the
list of private dependents of a type whose full view may become
visible subsequently.

From-SVN: r213483

gcc/ada/ChangeLog
gcc/ada/restrict.adb
gcc/ada/sem_ch3.adb

index 30c5d35a5d63a5c10e83dc2366bfcb9556a24bf9..cf119859b70ced991005747de0279711626c03de 100644 (file)
@@ -1,3 +1,17 @@
+2014-08-01  Ed Schonberg  <schonberg@adacore.com>
+
+       * restrict.adb (Update_Restrictions): For restrictions with a
+       maximum parameter (e.g. number of protected entries in Ravenscar)
+       do not compute the maximum of the violation over several objects,
+       because the restriction is per-object.
+       (Check_Restriction): After possible message, reset the value
+       of of a checked max_parameter restriction to zero, to prevent
+       cascaded errors.
+       * sem_ch3.adb (Build_Derived_Private_Type): Use base of parent
+       (sub)type to determine whether derived type should be on the
+       list of private dependents of a type whose full view may become
+       visible subsequently.
+
 2014-08-01  Olivier Hainque  <hainque@adacore.com>
 
        * gcc-interface/Make-lang.in (ADA_TOOLS_FLAGS_TO_PASS, native): use
index 3027ffa241cd465cdca59bc9317e223dce73d06c..ff44e6f75e46e8238e43df7dd20bce3e0643999b 100644 (file)
@@ -427,6 +427,7 @@ package body Restrict is
                if VV < 0 then
                   Info.Unknown (R) := True;
                   Info.Count (R) := 1;
+
                else
                   Info.Count (R) := VV;
                end if;
@@ -442,10 +443,11 @@ package body Restrict is
             if VV < 0 then
                Info.Unknown (R) := True;
 
-            --  If checked by maximization, do maximization
+            --  If checked by maximization, nothing to do because the
+            --  check is per-object.
 
             elsif R in Checked_Max_Parameter_Restrictions then
-               Info.Count (R) := Integer'Max (Info.Count (R), VV);
+               null;
 
             --  If checked by adding, do add, checking for overflow
 
@@ -554,6 +556,13 @@ package body Restrict is
          Msg_Issued := True;
          Restriction_Msg (R, N);
       end if;
+
+      --  For Max_Entries and the like, do not carry forward the violation
+      --  count because it does not affect later declarations.
+
+      if R in Checked_Max_Parameter_Restrictions then
+         Restrictions.Count (R) := 0;
+      end if;
    end Check_Restriction;
 
    -------------------------------------
index 871f543b03c9ab014c00c6668acbe86bfe172b97..ce46257525a40230c5c725bf9b6f164559f1880e 100644 (file)
@@ -6540,13 +6540,14 @@ package body Sem_Ch3 is
       Is_Completion : Boolean;
       Derive_Subps  : Boolean := True)
    is
-      Loc         : constant Source_Ptr := Sloc (N);
-      Der_Base    : Entity_Id;
-      Discr       : Entity_Id;
-      Full_Der    : Entity_Id;
-      Full_P      : Entity_Id;
-      Last_Discr  : Entity_Id;
-      Par_Scope   : constant Entity_Id := Scope (Base_Type (Parent_Type));
+      Loc        : constant Source_Ptr := Sloc (N);
+      Par_Base   : constant Entity_Id  := Base_Type (Parent_Type);
+      Par_Scope  : constant Entity_Id  := Scope (Par_Base);
+      Der_Base   : Entity_Id;
+      Discr      : Entity_Id;
+      Full_Der   : Entity_Id;
+      Full_P     : Entity_Id;
+      Last_Discr : Entity_Id;
 
       procedure Build_Full_Derivation;
       --  Build full derivation, i.e. derive from the full view
@@ -6984,10 +6985,12 @@ package body Sem_Ch3 is
          Set_Private_Dependents (Derived_Type, New_Elmt_List);
       end if;
 
-      if Is_Private_Type (Parent_Type)
-        and then Base_Type (Parent_Type) = Parent_Type
-        and then In_Open_Scopes (Scope (Parent_Type))
-      then
+      --  If the parent base type is in scope, add the derived type to its
+      --  list of private dependents, because its full view may become
+      --  visible subsequently (in a nested private part, a body, or in a
+      --  further child unit).
+
+      if Is_Private_Type (Par_Base) and then In_Open_Scopes (Par_Scope) then
          Append_Elmt (Derived_Type, Private_Dependents (Parent_Type));
 
          --  Check for unusual case where a type completed by a private
@@ -7008,9 +7011,9 @@ package body Sem_Ch3 is
          then
             --  In this case, the full view of the parent type will become
             --  visible in the body of the enclosing child, and only then will
-            --  the current type be possibly non-private. We build an
-            --  underlying full view that will be installed when the enclosing
-            --  child body is compiled.
+            --  the current type be possibly non-private. Build an underlying
+            --  full view that will be installed when the enclosing child body
+            --  is compiled.
 
             if Present (Underlying_Full_View (Derived_Type)) then
                Full_Der := Underlying_Full_View (Derived_Type);