aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/utils.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2009-10-17 11:17:27 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2009-10-17 11:17:27 +0000
commit431cfac1ffb50746d86afbf486f84180d39c54e8 (patch)
treed7e70992d9aba30711a5e73fff24f4b4d2d46b90 /gcc/ada/gcc-interface/utils.c
parent3f273c8a53e786389658f14a0316e48a5e0de0b6 (diff)
downloadgcc-431cfac1ffb50746d86afbf486f84180d39c54e8.zip
gcc-431cfac1ffb50746d86afbf486f84180d39c54e8.tar.gz
gcc-431cfac1ffb50746d86afbf486f84180d39c54e8.tar.bz2
utils.c (convert): When converting to a padded type with an inner type of self-referential size...
* gcc-interface/utils.c (convert): When converting to a padded type with an inner type of self-referential size, pad the expression before doing the unchecked conversion. From-SVN: r152935
Diffstat (limited to 'gcc/ada/gcc-interface/utils.c')
-rw-r--r--gcc/ada/gcc-interface/utils.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index 86575b5..a8225b0 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -3856,12 +3856,17 @@ convert (tree type, tree expr)
== TYPE_NAME (TREE_TYPE (TYPE_FIELDS (type))))))
return convert (type, TREE_OPERAND (expr, 0));
- /* If the result type is a padded type with a self-referentially-sized
- field and the expression type is a record, do this as an unchecked
- conversion. */
+ /* If the inner type is of self-referential size and the expression type
+ is a record, do this as an unchecked conversion. But first pad the
+ expression if possible to have the same size on both sides. */
if (TREE_CODE (etype) == RECORD_TYPE
&& CONTAINS_PLACEHOLDER_P (DECL_SIZE (TYPE_FIELDS (type))))
- return unchecked_convert (type, expr, false);
+ {
+ if (TREE_CONSTANT (TYPE_SIZE (etype)))
+ expr = convert (maybe_pad_type (etype, TYPE_SIZE (type), 0, Empty,
+ false, false, false, true), expr);
+ return unchecked_convert (type, expr, false);
+ }
/* If we are converting between array types with variable size, do the
final conversion as an unchecked conversion, again to avoid the need