diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2008-01-14 19:32:10 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2008-01-14 19:32:10 +0000 |
commit | 052cec9b0e00300eb75e6712cb82ad1e9d4ba3b4 (patch) | |
tree | 8cc6a97b41802b07368b171b5eddc2d051a9c406 /gcc/ada | |
parent | 8103eebfb73229a018f22718665864730e43c58f (diff) | |
download | gcc-052cec9b0e00300eb75e6712cb82ad1e9d4ba3b4.zip gcc-052cec9b0e00300eb75e6712cb82ad1e9d4ba3b4.tar.gz gcc-052cec9b0e00300eb75e6712cb82ad1e9d4ba3b4.tar.bz2 |
decl.c (gnat_to_gnu_entity): Process renamings before converting the expression to the type of the object.
* decl.c (gnat_to_gnu_entity) <object>: Process renamings
before converting the expression to the type of the object.
* trans.c (maybe_stabilize_reference) <CONSTRUCTOR>: New case.
Stabilize constructors for special wrapping types.
From-SVN: r131531
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/ada/decl.c | 37 | ||||
-rw-r--r-- | gcc/ada/trans.c | 22 |
3 files changed, 49 insertions, 17 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 563124c..1dd2fc5 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,10 @@ +2008-01-14 Eric Botcazou <ebotcazou@adacore.com> + + * decl.c (gnat_to_gnu_entity) <object>: Process renamings + before converting the expression to the type of the object. + * trans.c (maybe_stabilize_reference) <CONSTRUCTOR>: New case. + Stabilize constructors for special wrapping types. + 2008-01-13 Eric Botcazou <ebotcazou@adacore.com> * trans.c (call_to_gnu):Invoke the addressable_p predicate only diff --git a/gcc/ada/decl.c b/gcc/ada/decl.c index b61afce..2ddfe5a 100644 --- a/gcc/ada/decl.c +++ b/gcc/ada/decl.c @@ -740,23 +740,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) (TYPE_QUALS (gnu_type) | TYPE_QUAL_VOLATILE)); - /* Convert the expression to the type of the object except in the - case where the object's type is unconstrained or the object's type - is a padded record whose field is of self-referential size. In - the former case, converting will generate unnecessary evaluations - of the CONSTRUCTOR to compute the size and in the latter case, we - want to only copy the actual data. */ - if (gnu_expr - && TREE_CODE (gnu_type) != UNCONSTRAINED_ARRAY_TYPE - && !CONTAINS_PLACEHOLDER_P (TYPE_SIZE (gnu_type)) - && !(TREE_CODE (gnu_type) == RECORD_TYPE - && TYPE_IS_PADDING_P (gnu_type) - && (CONTAINS_PLACEHOLDER_P - (TYPE_SIZE (TREE_TYPE (TYPE_FIELDS (gnu_type))))))) - gnu_expr = convert (gnu_type, gnu_expr); - /* If this is a renaming, avoid as much as possible to create a new - object. However, in several cases, creating it is required. */ + object. However, in several cases, creating it is required. + This processing needs to be applied to the raw expression so + as to make it more likely to rename the underlying object. */ if (Present (Renamed_Object (gnat_entity))) { bool create_normal_object = false; @@ -905,7 +892,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) the object. If there is an initializer, it will have already been converted to the right type, but we need to create the template if there is no initializer. */ - else if (definition && TREE_CODE (gnu_type) == RECORD_TYPE + else if (definition + && TREE_CODE (gnu_type) == RECORD_TYPE && (TYPE_CONTAINS_TEMPLATE_P (gnu_type) /* Beware that padding might have been introduced via maybe_pad_type above. */ @@ -932,6 +920,21 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) NULL_TREE)); } + /* Convert the expression to the type of the object except in the + case where the object's type is unconstrained or the object's type + is a padded record whose field is of self-referential size. In + the former case, converting will generate unnecessary evaluations + of the CONSTRUCTOR to compute the size and in the latter case, we + want to only copy the actual data. */ + if (gnu_expr + && TREE_CODE (gnu_type) != UNCONSTRAINED_ARRAY_TYPE + && !CONTAINS_PLACEHOLDER_P (TYPE_SIZE (gnu_type)) + && !(TREE_CODE (gnu_type) == RECORD_TYPE + && TYPE_IS_PADDING_P (gnu_type) + && (CONTAINS_PLACEHOLDER_P + (TYPE_SIZE (TREE_TYPE (TYPE_FIELDS (gnu_type))))))) + gnu_expr = convert (gnu_type, gnu_expr); + /* If this is a pointer and it does not have an initializing expression, initialize it to NULL, unless the object is imported. */ diff --git a/gcc/ada/trans.c b/gcc/ada/trans.c index c5828d7..5b04972 100644 --- a/gcc/ada/trans.c +++ b/gcc/ada/trans.c @@ -6503,6 +6503,28 @@ maybe_stabilize_reference (tree ref, bool force, bool *success) result = gnat_stabilize_reference_1 (ref, force); break; + case CONSTRUCTOR: + /* Constructors with 1 element are used extensively to formally + convert objects to special wrapping types. */ + if (TREE_CODE (type) == RECORD_TYPE + && VEC_length (constructor_elt, CONSTRUCTOR_ELTS (ref)) == 1) + { + tree index + = VEC_index (constructor_elt, CONSTRUCTOR_ELTS (ref), 0)->index; + tree value + = VEC_index (constructor_elt, CONSTRUCTOR_ELTS (ref), 0)->value; + result + = build_constructor_single (type, index, + gnat_stabilize_reference_1 (value, + force)); + } + else + { + *success = false; + return ref; + } + break; + case ERROR_MARK: ref = error_mark_node; |