]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* tree-sra.c (bitfield_overlaps_p): Fix oversight.
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 3 Nov 2008 19:55:54 +0000 (19:55 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Mon, 3 Nov 2008 19:55:54 +0000 (19:55 +0000)
From-SVN: r141556

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/array5.adb [new file with mode: 0644]
gcc/tree-sra.c

index 0cd01eeb05a024334a217eb63b4b31464c5d2a18..210135528ec8fb4d05ba28ddfb999a730d8b9acb 100644 (file)
@@ -1,3 +1,7 @@
+2008-11-03  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * tree-sra.c (bitfield_overlaps_p): Fix oversight.
+
 2008-11-03  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>
 
        PR other/37463
index 06893ecd5b9728e541f5a798fb6ad597af074598..626145ef634167675a01fdde1e59d8c44884b488 100644 (file)
@@ -1,3 +1,7 @@
+2008-11-03  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/array5.adb New test.
+
 2008-11-03  Richard Guenther  <rguenther@suse.de>
        Jakub Jelinek  <jakub@redhat.com>
 
diff --git a/gcc/testsuite/gnat.dg/array5.adb b/gcc/testsuite/gnat.dg/array5.adb
new file mode 100644 (file)
index 0000000..72a5df8
--- /dev/null
@@ -0,0 +1,34 @@
+-- { dg-do run }
+-- { dg-options "-O" }
+
+procedure Array5 is
+
+    type myint is range 0 .. 100_000;
+    Bla : constant myint := 359;
+
+    type my_array is array (1 .. 2) of myint;
+
+    type item is record
+       Length  : Integer;
+       Content : my_array;
+    end record;
+
+    procedure create_item (M : out item) is
+    begin
+      M.Length := 1;
+      M.Content := (others => Bla);
+    end;
+
+    Var : item;
+
+begin
+    create_item (Var);
+
+    if Var.Length = 1
+     and then Var.Content (1) = Bla
+    then
+      null;
+    else
+      raise Program_Error;
+    end if;
+end;
index 3689b69f757ea83e100af6e344a4694973f7f243..60330b14bc5cc7337c010757dbf6582b5fffa4cc 100644 (file)
@@ -2961,8 +2961,13 @@ bitfield_overlaps_p (tree blen, tree bpos, struct sra_elt *fld,
     }
   else if (TREE_CODE (fld->element) == INTEGER_CST)
     {
+      tree domain_type = TYPE_DOMAIN (TREE_TYPE (fld->parent->element));
       flen = fold_convert (bitsizetype, TYPE_SIZE (fld->type));
       fpos = fold_convert (bitsizetype, fld->element);
+      if (domain_type && TYPE_MIN_VALUE (domain_type))
+       fpos = size_binop (MINUS_EXPR, fpos,
+                          fold_convert (bitsizetype,
+                                        TYPE_MIN_VALUE (domain_type)));
       fpos = size_binop (MULT_EXPR, flen, fpos);
     }
   else