diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2007-09-11 19:43:02 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2007-09-11 19:43:02 +0000 |
commit | fa89b6ecba4ce9448b82a21f91b360eacf57bc72 (patch) | |
tree | 6794bfdde0fa3a761d0a915bf86007b0ca87d7e2 /gcc/ada/utils.c | |
parent | 868eaa1f422576b092cc1bdcf576d4cfa3d18fb3 (diff) | |
download | gcc-fa89b6ecba4ce9448b82a21f91b360eacf57bc72.zip gcc-fa89b6ecba4ce9448b82a21f91b360eacf57bc72.tar.gz gcc-fa89b6ecba4ce9448b82a21f91b360eacf57bc72.tar.bz2 |
tree-ssa-structalias.c (push_fields_onto_fieldstack): Deal with TYPE_NONALIASED_COMPONENT like with DECL_NONADDRESSABLE_P.
* tree-ssa-structalias.c (push_fields_onto_fieldstack): Deal with
TYPE_NONALIASED_COMPONENT like with DECL_NONADDRESSABLE_P.
ada/
* decl.c (array_type_has_nonaliased_component): New predicate.
(gnat_to_gnu_field) <E_Array_Type>: Invoke the above predicate to
set the TYPE_NONALIASED_COMPONENT flag on the type.
<E_Array_Subtype>: Likewise.
* gigi.h (type_for_nonaliased_component_p): Declare.
* utils.c (type_for_nonaliased_component_p): New predicate.
(create_field_decl): Invoke the above predicate to set the
DECL_NONADDRESSABLE_P flag on the field.
From-SVN: r128391
Diffstat (limited to 'gcc/ada/utils.c')
-rw-r--r-- | gcc/ada/utils.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/gcc/ada/utils.c b/gcc/ada/utils.c index 6a4cc3c..56d4900 100644 --- a/gcc/ada/utils.c +++ b/gcc/ada/utils.c @@ -1625,21 +1625,14 @@ create_field_decl (tree field_name, tree field_type, tree record_type, } /* In addition to what our caller says, claim the field is addressable if we - know we might ever attempt to take its address, then mark the decl as - nonaddressable accordingly. + know that its type is not suitable. The field may also be "technically" nonaddressable, meaning that even if we attempt to take the field's address we will actually get the address of a copy. This is the case for true bitfields, but the DECL_BIT_FIELD value we have at this point is not accurate enough, so we don't account for this here and let finish_record_type decide. */ - - /* We will take the address in any argument passing sequence if the field - type is passed by reference, and we might need the address for any array - type, even if normally passed by-copy, to construct a fat pointer if the - field is used as an actual for an unconstrained formal. */ - if (TREE_CODE (field_type) == ARRAY_TYPE - || must_pass_by_ref (field_type) || default_pass_by_ref (field_type)) + if (!type_for_nonaliased_component_p (field_type)) addressable = 1; DECL_NONADDRESSABLE_P (field_decl) = !addressable; @@ -4004,6 +3997,26 @@ tree_code_for_record_type (Entity_Id gnat_type) return UNION_TYPE; } +/* Return true if GNU_TYPE is suitable as the type of a non-aliased + component of an aggregate type. */ + +bool +type_for_nonaliased_component_p (tree gnu_type) +{ + /* If the type is passed by reference, we may have pointers to the + component so it cannot be made non-aliased. */ + if (must_pass_by_ref (gnu_type) || default_pass_by_ref (gnu_type)) + return false; + + /* We might need the address for any array type, even if normally + passed by copy, to construct a fat pointer if the component is + used as an actual for an unconstrained formal. */ + if (TREE_CODE (gnu_type) == ARRAY_TYPE) + return false; + + return true; +} + /* Perform final processing on global variables. */ void |