* decl.c (is_variable_size): Do not unconditionally return false
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 6 Apr 2008 13:38:41 +0000 (13:38 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 6 Apr 2008 13:38:41 +0000 (13:38 +0000)
on non-strict alignment platforms.

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

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

index a6f1403..4ed6a52 100644 (file)
@@ -1,5 +1,10 @@
 2008-04-06  Eric Botcazou  <ebotcazou@adacore.com>
 
+       * decl.c (is_variable_size): Do not unconditionally return false
+       on non-strict alignment platforms.
+
+2008-04-06  Eric Botcazou  <ebotcazou@adacore.com>
+
        * decl.c (rest_of_type_decl_compilation_no_defer): New local function
        used to process all the variants of the specified type.
        (gnat_to_gnu_entity): Invoke rest_of_type_decl_compilation for enumeral
index e31b525..bda144e 100644 (file)
@@ -6103,18 +6103,17 @@ is_variable_size (tree type)
 {
   tree field;
 
-  /* We need not be concerned about this at all if we don't have
-     strict alignment.  */
-  if (!STRICT_ALIGNMENT)
-    return false;
-  else if (!TREE_CONSTANT (TYPE_SIZE (type)))
+  if (!TREE_CONSTANT (TYPE_SIZE (type)))
     return true;
-  else if (TREE_CODE (type) == RECORD_TYPE && TYPE_IS_PADDING_P (type)
-          && !TREE_CONSTANT (DECL_SIZE (TYPE_FIELDS (type))))
+
+  if (TREE_CODE (type) == RECORD_TYPE
+      && TYPE_IS_PADDING_P (type)
+      && !TREE_CONSTANT (DECL_SIZE (TYPE_FIELDS (type))))
     return true;
-  else if (TREE_CODE (type) != RECORD_TYPE
-          && TREE_CODE (type) != UNION_TYPE
-          && TREE_CODE (type) != QUAL_UNION_TYPE)
+
+  if (TREE_CODE (type) != RECORD_TYPE
+      && TREE_CODE (type) != UNION_TYPE
+      && TREE_CODE (type) != QUAL_UNION_TYPE)
     return false;
 
   for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
index ee449b6..9fc756e 100644 (file)
@@ -1,3 +1,7 @@
+2008-04-06  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/pack5.adb: New test.
+
 2008-04-06  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/12329
diff --git a/gcc/testsuite/gnat.dg/pack5.adb b/gcc/testsuite/gnat.dg/pack5.adb
new file mode 100644 (file)
index 0000000..12bea11
--- /dev/null
@@ -0,0 +1,32 @@
+-- { dg-do compile }
+
+procedure Pack5 is
+
+  type Kind is (v1, v2, v3);
+
+  type Error (k : Kind := Kind'First) is record
+    case k is
+    when v1 =>
+      null;
+    when v2 =>
+      null;
+    when Others =>
+      B : Boolean;
+    end case;
+  end record;
+  pragma Pack (Error);
+  for Error'Size use 16;
+
+  No_Error: constant Error := (k => v2);
+
+  type R (B : Boolean) is record
+    E : Error;
+  end record;
+  pragma Pack(R);
+  type Ptr is access R;
+
+  C : Ptr := new R (True);
+
+begin
+  C.E := No_Error;
+end;