]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
decl.c (gnat_to_gnu_entity): Do not consider that regular packed arrays can never...
authorEric Botcazou <ebotcazou@adacore.com>
Sun, 18 May 2014 17:51:15 +0000 (17:51 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Sun, 18 May 2014 17:51:15 +0000 (17:51 +0000)
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Array_Subtype>: Do not
consider that regular packed arrays can never be superflat.

From-SVN: r210583

gcc/ada/ChangeLog
gcc/ada/gcc-interface/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/enum3.adb [new file with mode: 0644]

index 0102460767c69ed9c59b8cd79b286382a0ea5165..c1e01de4b8d4b9a69b97a8c7c974b4f676ba1b19 100644 (file)
@@ -1,3 +1,8 @@
+2014-05-18  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Array_Subtype>: Do not
+       consider that regular packed arrays can never be superflat.
+
 2014-05-17  Trevor Saunders  <tsaunders@mozilla.com>
 
        * gcc-interface/ada-tree.h: Remove usage of variable_size gty
index ff1210e6c87cd166df357e140eb95515b53a81d6..59ec0571b66c68ea5a903a9503e502d278cc71ba 100644 (file)
@@ -2420,8 +2420,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
                 we can just use the high bound of the index type.  */
              else if ((Nkind (gnat_index) == N_Range
                        && cannot_be_superflat_p (gnat_index))
-                      /* Packed Array Types are never superflat.  */
-                      || Is_Packed_Array_Type (gnat_entity))
+                      /* Bit-Packed Array Types are never superflat.  */
+                      || (Is_Packed_Array_Type (gnat_entity)
+                          && Is_Bit_Packed_Array
+                             (Original_Array_Type (gnat_entity))))
                gnu_high = gnu_max;
 
              /* Otherwise, if the high bound is constant but the low bound is
index fbb18caaf7b20300fa6e71221c92a41c23d19bfe..a186323cd4af1c887cb7d3a06facee1826e8830b 100644 (file)
@@ -1,3 +1,7 @@
+2014-05-18  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/enum3.adb: New test.
+
 2014-05-18  Andreas Schwab  <schwab@suse.de>
 
        * gcc.target/ia64/visibility-1.c (variable_l): Add used attribute.
diff --git a/gcc/testsuite/gnat.dg/enum3.adb b/gcc/testsuite/gnat.dg/enum3.adb
new file mode 100644 (file)
index 0000000..1cb6c4b
--- /dev/null
@@ -0,0 +1,23 @@
+-- { dg-do run }
+
+procedure Enum3 is
+   type Enum is (Aaa, Bbb, Ccc);
+   for Enum use (1,2,4);
+begin
+   for Lo in Enum loop
+      for Hi in Enum loop
+         declare
+            subtype S is Enum range Lo .. Hi;
+            type Vector is array (S) of Integer;
+            Vec : Vector;
+         begin
+            for I in S loop
+               Vec (I) := 0;
+            end loop;
+            if Vec /= (S => 0) then
+               raise Program_Error;
+            end if;
+         end;
+      end loop;
+   end loop;
+end;