* decl.c (components_to_record): Zero the alignment of the qualified
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 3 May 2008 19:47:22 +0000 (19:47 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 3 May 2008 19:47:22 +0000 (19:47 +0000)
union built for the variant part upon creating it.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@134917 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/ChangeLog
gcc/ada/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/discr6.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/discr6_pkg.ads [new file with mode: 0644]

index 6da64b6..28cf5dc 100644 (file)
@@ -1,5 +1,10 @@
 2008-05-03  Eric Botcazou  <ebotcazou@adacore.com>
 
+       * decl.c (components_to_record): Zero the alignment of the qualified
+       union built for the variant part upon creating it.
+
+2008-05-03  Eric Botcazou  <ebotcazou@adacore.com>
+
        * decl.c (maybe_pad_type): Try to get a form of the type with integral
        mode even if the alignment is not a factor of the original size.  But
        make sure to create the inner field with the original size.  Reorder.
index 9d933b7..68ea42b 100644 (file)
@@ -6322,6 +6322,7 @@ components_to_record (tree gnu_record_type, Node_Id component_list,
            = make_node (unchecked_union ? UNION_TYPE : QUAL_UNION_TYPE);
 
          TYPE_NAME (gnu_union_type) = gnu_union_name;
+         TYPE_ALIGN (gnu_union_type) = 0;
          TYPE_PACKED (gnu_union_type) = TYPE_PACKED (gnu_record_type);
        }
 
index 53a4fc0..a8880ad 100644 (file)
@@ -1,5 +1,10 @@
 2008-05-03  Eric Botcazou  <ebotcazou@adacore.com>
 
+       * gnat.dg/discr6_pkg.ads: New helper.
+       * gnat.dg/discr6.adb: New test.
+
+2008-05-03  Eric Botcazou  <ebotcazou@adacore.com>
+
        * gnat.dg/alignment4.adb: Adjust.
        * gnat.dg/alignment5.adb: Likewise.
        * gnat.dg/alignment6.adb: XFAIL.
diff --git a/gcc/testsuite/gnat.dg/discr6.adb b/gcc/testsuite/gnat.dg/discr6.adb
new file mode 100644 (file)
index 0000000..441b19b
--- /dev/null
@@ -0,0 +1,33 @@
+-- { dg-do compile }\r
+-- { dg-options "-gnatdm -gnatws" }\r
+\r
+with Discr6_Pkg;\r
+\r
+procedure Discr6 is\r
+\r
+  type T_Bit is range 0..1;\r
+  type T_Entier_16 is range -2**15 .. 2**15-1;\r
+\r
+  package My_Q is new Discr6_Pkg(T_Entier_16);\r
+\r
+  type T_Valeur is (BIT, Entier_16);\r
+\r
+  type R(D : T_Valeur) is record\r
+    case D is\r
+      when BIT => V_BIT : T_Bit;\r
+      when Entier_16 => V_E16 : T_Entier_16;\r
+    end case;\r
+  end record;\r
+  for R use record\r
+    V_BIT at 0 range 0..7;\r
+    V_E16 at 0 range 0..15;\r
+    D     at 8 range 0..7;\r
+  end record;\r
+  for R'size use 128;\r
+\r
+  A : R(Entier_16);\r
+  I : Integer;\r
+\r
+begin\r
+  I := My_Q.X(A.V_E16);\r
+end;\r
diff --git a/gcc/testsuite/gnat.dg/discr6_pkg.ads b/gcc/testsuite/gnat.dg/discr6_pkg.ads
new file mode 100644 (file)
index 0000000..11d713c
--- /dev/null
@@ -0,0 +1,16 @@
+generic\r
+\r
+  type T(<>) is private;\r
+\r
+package Discr6_Pkg is\r
+\r
+  function X (A : T) return Integer;\r
+\r
+  pragma Interface(C, X);\r
+  pragma IMPORT_FUNCTION (\r
+         INTERNAL         => X,\r
+         EXTERNAL         => X,\r
+         PARAMETER_TYPES  => (T),\r
+         MECHANISM        => (Descriptor(S)));\r
+\r
+end Discr6_Pkg;\r