From 2d091b12a0466d34d78d696bed390f3792ffe9fa Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Sun, 6 Apr 2008 13:38:41 +0000 Subject: [PATCH] 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 --- gcc/ada/ChangeLog | 5 +++++ gcc/ada/decl.c | 19 +++++++++---------- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gnat.dg/pack5.adb | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 10 deletions(-) create mode 100644 gcc/testsuite/gnat.dg/pack5.adb diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index a6f1403..4ed6a52 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,5 +1,10 @@ 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 used to process all the variants of the specified type. (gnat_to_gnu_entity): Invoke rest_of_type_decl_compilation for enumeral diff --git a/gcc/ada/decl.c b/gcc/ada/decl.c index e31b525..bda144e 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 ee449b6..9fc756e 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 0000000..12bea11 --- /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; -- 2.7.4