diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2008-09-17 21:48:08 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2008-09-17 21:48:08 +0000 |
commit | 1a8c909ebd0bbd58ed5308bc66dc923ec5cfaafd (patch) | |
tree | b323580342f5e9faae9bf584a093129a2b0fa96d /gcc/varasm.c | |
parent | 9f509004fcba4e2ef649c347f679108fefdff122 (diff) | |
download | gcc-1a8c909ebd0bbd58ed5308bc66dc923ec5cfaafd.zip gcc-1a8c909ebd0bbd58ed5308bc66dc923ec5cfaafd.tar.gz gcc-1a8c909ebd0bbd58ed5308bc66dc923ec5cfaafd.tar.bz2 |
varasm.c (initializer_constant_valid_p): Forbid view-conversions from aggregate to non-aggregate type if...
* varasm.c (initializer_constant_valid_p): Forbid view-conversions
from aggregate to non-aggregate type if the bit pattern is not fully
preserved afterwards.
From-SVN: r140432
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r-- | gcc/varasm.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/gcc/varasm.c b/gcc/varasm.c index 5728d19..e74adae 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -4205,19 +4205,36 @@ initializer_constant_valid_p (tree value, tree endtype) return op0; } - case VIEW_CONVERT_EXPR: case NON_LVALUE_EXPR: return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype); - CASE_CONVERT: + case VIEW_CONVERT_EXPR: { - tree src; - tree src_type; - tree dest_type; + tree src = TREE_OPERAND (value, 0); + tree src_type = TREE_TYPE (src); + tree dest_type = TREE_TYPE (value); + + /* Allow view-conversions from aggregate to non-aggregate type only + if the bit pattern is fully preserved afterwards; otherwise, the + RTL expander won't be able to apply a subsequent transformation + to the underlying constructor. */ + if (AGGREGATE_TYPE_P (src_type) && !AGGREGATE_TYPE_P (dest_type)) + { + if (TYPE_MODE (endtype) == TYPE_MODE (dest_type)) + return initializer_constant_valid_p (src, endtype); + else + return NULL_TREE; + } + + /* Allow all other kinds of view-conversion. */ + return initializer_constant_valid_p (src, endtype); + } - src = TREE_OPERAND (value, 0); - src_type = TREE_TYPE (src); - dest_type = TREE_TYPE (value); + CASE_CONVERT: + { + tree src = TREE_OPERAND (value, 0); + tree src_type = TREE_TYPE (src); + tree dest_type = TREE_TYPE (value); /* Allow conversions between pointer types, floating-point types, and offset types. */ |