[gcc r11-5307] [Ada] Reuse Is_Packed_Array where possible

Pierre-Marie de Rodat pmderodat@gcc.gnu.org
Tue Nov 24 10:19:15 GMT 2020


https://gcc.gnu.org/g:bfe5f951ce9d7fb205aa08d5a6dad699398417d9

commit r11-5307-gbfe5f951ce9d7fb205aa08d5a6dad699398417d9
Author: Piotr Trojanek <trojanek@adacore.com>
Date:   Thu Oct 8 23:55:49 2020 +0200

    [Ada] Reuse Is_Packed_Array where possible
    
    gcc/ada/
    
            * exp_attr.adb, exp_ch4.adb, exp_intr.adb, sem_ch8.adb,
            sem_res.adb, sem_type.adb, sem_util.adb: Reuse Is_Packed_Array.

Diff:
---
 gcc/ada/exp_attr.adb | 10 ++++------
 gcc/ada/exp_ch4.adb  |  3 +--
 gcc/ada/exp_intr.adb |  5 ++---
 gcc/ada/sem_ch8.adb  |  3 +--
 gcc/ada/sem_res.adb  |  3 +--
 gcc/ada/sem_type.adb |  6 ++----
 gcc/ada/sem_util.adb |  3 +--
 7 files changed, 12 insertions(+), 21 deletions(-)

diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb
index 70e13359a7e..cabe891ade0 100644
--- a/gcc/ada/exp_attr.adb
+++ b/gcc/ada/exp_attr.adb
@@ -4235,7 +4235,7 @@ package body Exp_Attr is
       begin
          --  Processing for packed array types
 
-         if Is_Array_Type (Ptyp) and then Is_Packed (Ptyp) then
+         if Is_Packed_Array (Ptyp) then
             Ityp := Get_Index_Subtype (N);
 
             --  If the index type, Ityp, is an enumeration type with holes,
@@ -4333,7 +4333,7 @@ package body Exp_Attr is
                Xtyp : Entity_Id;
 
             begin
-               if Is_Array_Type (Dtyp) and then Is_Packed (Dtyp) then
+               if Is_Packed_Array (Dtyp) then
                   Xtyp := Get_Index_Subtype (N);
 
                   Rewrite (N,
@@ -7869,8 +7869,7 @@ package body Exp_Attr is
 
          if Is_Entity_Name (Pref)
            and then Is_Formal (Entity (Pref))
-           and then Is_Array_Type (Ptyp)
-           and then Is_Packed (Ptyp)
+           and then Is_Packed_Array (Ptyp)
          then
             Rewrite (N,
               Make_Attribute_Reference (Loc,
@@ -7884,9 +7883,8 @@ package body Exp_Attr is
          --  type, but also a hint to the actual constrained type.
 
          elsif Nkind (Pref) = N_Explicit_Dereference
-           and then Is_Array_Type (Ptyp)
+           and then Is_Packed_Array (Ptyp)
            and then not Is_Constrained (Ptyp)
-           and then Is_Packed (Ptyp)
          then
             Set_Actual_Designated_Subtype (Pref, Get_Actual_Subtype (Pref));
 
diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
index 076e0def302..102f7ae6bd6 100644
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -1268,9 +1268,8 @@ package body Exp_Ch4 is
          --  expression with a constrained subtype in order to compute the
          --  proper size for the allocator.
 
-         if Is_Array_Type (T)
+         if Is_Packed_Array (T)
            and then not Is_Constrained (T)
-           and then Is_Packed (T)
          then
             declare
                ConstrT      : constant Entity_Id := Make_Temporary (Loc, 'A');
diff --git a/gcc/ada/exp_intr.adb b/gcc/ada/exp_intr.adb
index 78bde893aa4..7fc00c706f2 100644
--- a/gcc/ada/exp_intr.adb
+++ b/gcc/ada/exp_intr.adb
@@ -1229,9 +1229,8 @@ package body Exp_Intr is
 
          if Is_Class_Wide_Type (Desig_Typ)
            or else
-            (Is_Array_Type (Desig_Typ)
-              and then not Is_Constrained (Desig_Typ)
-              and then Is_Packed (Desig_Typ))
+            (Is_Packed_Array (Desig_Typ)
+              and then not Is_Constrained (Desig_Typ))
          then
             declare
                Deref    : constant Node_Id :=
diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb
index 69430a69375..9404d6884af 100644
--- a/gcc/ada/sem_ch8.adb
+++ b/gcc/ada/sem_ch8.adb
@@ -5659,8 +5659,7 @@ package body Sem_Ch8 is
                --  happens for trees generated from Exp_Pakd, where expressions
                --  can be deliberately "mis-typed" to the packed array type.
 
-               if Is_Array_Type (Entyp)
-                 and then Is_Packed (Entyp)
+               if Is_Packed_Array (Entyp)
                  and then Present (Etype (N))
                  and then Etype (N) = Packed_Array_Impl_Type (Entyp)
                then
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index f2f0a12bef0..f522da005b1 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -8849,8 +8849,7 @@ package body Sem_Res is
       --  actual subtype. We also exclude generated code (which builds actual
       --  subtypes directly if they are needed).
 
-      if Is_Array_Type (Etype (N))
-        and then Is_Packed (Etype (N))
+      if Is_Packed_Array (Etype (N))
         and then not Is_Constrained (Etype (N))
         and then Nkind (Parent (N)) /= N_Attribute_Reference
         and then Comes_From_Source (N)
diff --git a/gcc/ada/sem_type.adb b/gcc/ada/sem_type.adb
index 4b5224938af..8dbfa182923 100644
--- a/gcc/ada/sem_type.adb
+++ b/gcc/ada/sem_type.adb
@@ -1167,16 +1167,14 @@ package body Sem_Type is
       --  useless unchecked conversions, and since this can only arise in
       --  (known correct) expanded code, no harm is done.
 
-      elsif Is_Array_Type (T2)
-        and then Is_Packed (T2)
+      elsif Is_Packed_Array (T2)
         and then T1 = Packed_Array_Impl_Type (T2)
       then
          return True;
 
       --  Similarly an array type covers its corresponding packed array type
 
-      elsif Is_Array_Type (T1)
-        and then Is_Packed (T1)
+      elsif Is_Packed_Array (T1)
         and then T2 = Packed_Array_Impl_Type (T1)
       then
          return True;
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 3af4f3a4e12..db348ec7550 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -20450,8 +20450,7 @@ package body Sem_Util is
 
          elsif Nkind (P) = N_Type_Conversion
            and then not Comes_From_Source (P)
-           and then Is_Array_Type (Etype (P))
-           and then Is_Packed (Etype (P))
+           and then Is_Packed_Array (Etype (P))
          then
             return Is_Variable (Expression (P));


More information about the Gcc-cvs mailing list