public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Fix wrong code generated for superflat array
@ 2014-05-18 17:53 Eric Botcazou
  0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2014-05-18 17:53 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 518 bytes --]

This is a regression present on the mainline and 4.9 branch for a corner case: 
a superflat array indexed by an enumeration type with representation clause.

Tested on x86_64-suse-linux, applied on the mainline and 4.9 branch.


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-18  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/enum3.adb: New test.


-- 
Eric Botcazou

[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 791 bytes --]

Index: gcc-interface/decl.c
===================================================================
--- gcc-interface/decl.c	(revision 210579)
+++ gcc-interface/decl.c	(working copy)
@@ -2420,8 +2420,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 		 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

[-- Attachment #3: enum3.adb --]
[-- Type: text/x-adasrc, Size: 522 bytes --]

-- { 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;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-05-18 17:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-18 17:53 [Ada] Fix wrong code generated for superflat array Eric Botcazou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).