From: Eric Botcazou Date: Sun, 6 Apr 2008 13:38:41 +0000 (+0000) Subject: decl.c (is_variable_size): Do not unconditionally return false on non-strict alignmen... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2d091b12a0466d34d78d696bed390f3792ffe9fa;p=gcc.git decl.c (is_variable_size): Do not unconditionally return false on non-strict alignment platforms. * decl.c (is_variable_size): Do not unconditionally return false on non-strict alignment platforms. From-SVN: r133961 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index a6f14035db3..4ed6a527de2 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2008-04-06 Eric Botcazou + + * decl.c (is_variable_size): Do not unconditionally return false + on non-strict alignment platforms. + 2008-04-06 Eric Botcazou * decl.c (rest_of_type_decl_compilation_no_defer): New local function diff --git a/gcc/ada/decl.c b/gcc/ada/decl.c index e31b52528ed..bda144e3879 100644 --- a/gcc/ada/decl.c +++ b/gcc/ada/decl.c @@ -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)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ee449b600e3..9fc756e0128 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2008-04-06 Eric Botcazou + + * gnat.dg/pack5.adb: New test. + 2008-04-06 Uros Bizjak PR target/12329 diff --git a/gcc/testsuite/gnat.dg/pack5.adb b/gcc/testsuite/gnat.dg/pack5.adb new file mode 100644 index 00000000000..12bea11a311 --- /dev/null +++ b/gcc/testsuite/gnat.dg/pack5.adb @@ -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;