tree-sra.c (sra_type_can_be_decomposed_p): Make sure that the bitfield is of integral...
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 27 May 2008 11:00:38 +0000 (11:00 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Tue, 27 May 2008 11:00:38 +0000 (11:00 +0000)
* tree-sra.c (sra_type_can_be_decomposed_p) <RECORD_TYPE>: Make sure
that the bitfield is of integral type before testing its precision.

From-SVN: r136009

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

index d7e50ad6a1a7be88a89023ebb430d97c76f5a41e..d373b1bf31473f2c78b33ba02a43944761b85c70 100644 (file)
@@ -1,3 +1,8 @@
+2008-05-27  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * tree-sra.c (sra_type_can_be_decomposed_p) <RECORD_TYPE>: Make sure
+       that the bitfield is of integral type before testing its precision.
+
 2008-05-27  Trevor Smigiel  <trevor_smigiel@playstation.sony.com>
            Sa Liu  <saliu@de.ibm.com> 
 
index a34e1a19b56f77b0d6204eeaab1f3b249c167847..d1eb120f035be0e4915c02cd048e93929f1b0a36 100644 (file)
@@ -1,3 +1,7 @@
+2008-05-27  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/pack9.ad[sb]: New test.
+
 2008-05-27  Arnaud Charlet  <charlet@adacore.com>
 
        * gnat.dg/sync1.ad[sb]: New test.
diff --git a/gcc/testsuite/gnat.dg/pack9.adb b/gcc/testsuite/gnat.dg/pack9.adb
new file mode 100644 (file)
index 0000000..894ecd6
--- /dev/null
@@ -0,0 +1,18 @@
+-- { dg-do compile }
+-- { dg-options "-O2 -gnatp -cargs --param sra-max-structure-size=24 --param sra-max-structure-count=6 -fdump-tree-final_cleanup" }
+
+package body Pack9 is
+
+  procedure Copy (X, Y : R2_Ptr) is
+    T : R2 := Y.all;
+  begin
+    if T.I2 /= Y.I2 then
+      raise Program_Error;
+    end if;
+    X.all := T;
+  end;
+
+end Pack9;
+
+-- { dg-final { scan-tree-dump-not "__gnat_rcheck" "final_cleanup" } }
+-- { dg-final { cleanup-tree-dump "final_cleanup" } }
diff --git a/gcc/testsuite/gnat.dg/pack9.ads b/gcc/testsuite/gnat.dg/pack9.ads
new file mode 100644 (file)
index 0000000..00202a9
--- /dev/null
@@ -0,0 +1,18 @@
+package Pack9 is
+
+  type R1 is record
+    I : Integer;
+    C : Character;
+  end record;
+
+  type R2 is record
+    I1, I2 : Integer;
+    A : R1;
+  end record;
+  pragma Pack(R2);
+
+  type R2_Ptr is access all R2;
+
+  procedure Copy (X, Y : R2_Ptr);
+
+end Pack9;
index 9e15f928bf3824f743af7229d935b639cb92f39e..244219ffe79175d07ef0821c945fb623c47de703 100644 (file)
@@ -268,6 +268,7 @@ sra_type_can_be_decomposed_p (tree type)
            {
              /* Reject incorrectly represented bit fields.  */
              if (DECL_BIT_FIELD (t)
+                 && INTEGRAL_TYPE_P (TREE_TYPE (t))
                  && (tree_low_cst (DECL_SIZE (t), 1)
                      != TYPE_PRECISION (TREE_TYPE (t))))
                goto fail;