diff options
author | hainque <hainque@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-06-01 15:27:59 +0000 |
---|---|---|
committer | hainque <hainque@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-06-01 15:27:59 +0000 |
commit | d515c104644270bc261722345e03cecc798703c6 (patch) | |
tree | ecb474a41df463273bc0efc8acb2f9b87af38038 /gcc/ada | |
parent | 69e84e89b0e5ada5dc7aeed144bc750f0436843e (diff) | |
download | gcc-d515c104644270bc261722345e03cecc798703c6.tar.gz |
ada/
* gcc-interface/utils.c (convert) <CONSTRUCTOR case>: When converting
to the packable version of the type, clear TREE_STATIC/TREE_CONSTANT
on the result if at least one of the input fields couldn't be output
as a static constant any more.
testsuite/
* gnat.dg/nested_float_packed.ads: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@148049 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/utils.c | 19 |
2 files changed, 27 insertions, 0 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 51be8bf3a22..c3f7219fd67 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,6 +1,14 @@ 2009-06-01 Olivier Hainque <hainque@adacore.com> Eric Botcazou <botcazou@adacore.com> + * gcc-interface/utils.c (convert) <CONSTRUCTOR case>: When converting + to the packable version of the type, clear TREE_STATIC/TREE_CONSTANT + on the result if at least one of the input fields couldn't be output + as a static constant any more. + +2009-06-01 Olivier Hainque <hainque@adacore.com> + Eric Botcazou <botcazou@adacore.com> + * gcc-interface/utils2.c (gnat_build_constructor): Factor out code. Use initializer_constant_valid_for_bitfield_p and CONSTRUCTOR_BITFIELD_P for bit-fields. diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index 6dbd1e700e1..f3755a01631 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -3979,6 +3979,10 @@ convert (tree type, tree expr) unsigned HOST_WIDE_INT idx; tree index, value; + /* Whether we need to clear TREE_CONSTANT et al. on the output + constructor when we convert in place. */ + bool clear_constant = false; + FOR_EACH_CONSTRUCTOR_ELT(e, idx, index, value) { constructor_elt *elt = VEC_quick_push (constructor_elt, v, NULL); @@ -3987,15 +3991,30 @@ convert (tree type, tree expr) break; elt->index = field; elt->value = convert (TREE_TYPE (field), value); + + /* If packing has made this field a bitfield and the input + value couldn't be emitted statically any more, we need to + clear TREE_CONSTANT on our output. */ + if (!clear_constant && TREE_CONSTANT (expr) + && !CONSTRUCTOR_BITFIELD_P (efield) + && CONSTRUCTOR_BITFIELD_P (field) + && !initializer_constant_valid_for_bitfield_p (value)) + clear_constant = true; + efield = TREE_CHAIN (efield); field = TREE_CHAIN (field); } + /* If we have been able to match and convert all the input fields + to their output type, convert in place now. We'll fallback to a + view conversion downstream otherwise. */ if (idx == len) { expr = copy_node (expr); TREE_TYPE (expr) = type; CONSTRUCTOR_ELTS (expr) = v; + if (clear_constant) + TREE_CONSTANT (expr) = TREE_STATIC (expr) = false; return expr; } } |