diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2009-10-27 20:24:31 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2009-10-27 20:24:31 +0000 |
commit | 73d28034382a7ba65ec46d6a1cebd828f32b16c9 (patch) | |
tree | 9b464e77c6b2ce6811550a99c1c7c80f30a27a17 /gcc/ada/gcc-interface/decl.c | |
parent | b7da9fd42dca6efbba34efa78539bfa14b3f4e39 (diff) | |
download | gcc-73d28034382a7ba65ec46d6a1cebd828f32b16c9.zip gcc-73d28034382a7ba65ec46d6a1cebd828f32b16c9.tar.gz gcc-73d28034382a7ba65ec46d6a1cebd828f32b16c9.tar.bz2 |
decl.c (purpose_member_field): New static function.
* gcc-interface/decl.c (purpose_member_field): New static function.
(annotate_rep): Use it instead of purpose_member.
From-SVN: r153616
Diffstat (limited to 'gcc/ada/gcc-interface/decl.c')
-rw-r--r-- | gcc/ada/gcc-interface/decl.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 6abb366..c3766ee 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -7231,6 +7231,23 @@ annotate_object (Entity_Id gnat_entity, tree gnu_type, tree size, bool by_ref) UI_From_Int (TYPE_ALIGN (gnu_type) / BITS_PER_UNIT)); } +/* Return first element of field list whose TREE_PURPOSE is ELEM or whose + DECL_ORIGINAL_FIELD of TREE_PURPOSE is ELEM. Return NULL_TREE if there + is no such element in the list. */ + +static tree +purpose_member_field (const_tree elem, tree list) +{ + while (list) + { + tree field = TREE_PURPOSE (list); + if (elem == field || elem == DECL_ORIGINAL_FIELD (field)) + return list; + list = TREE_CHAIN (list); + } + return NULL_TREE; +} + /* Given GNAT_ENTITY, a record type, and GNU_TYPE, its corresponding GCC type, set Component_Bit_Offset and Esize of the components to the position and size used by Gigi. */ @@ -7254,11 +7271,12 @@ annotate_rep (Entity_Id gnat_entity, tree gnu_type) || (Ekind (gnat_field) == E_Discriminant && !Is_Unchecked_Union (Scope (gnat_field)))) { - tree parent_offset, t; - - t = purpose_member (gnat_to_gnu_field_decl (gnat_field), gnu_list); + tree t = purpose_member_field (gnat_to_gnu_field_decl (gnat_field), + gnu_list); if (t) { + tree parent_offset; + if (type_annotate_only && Is_Tagged_Type (gnat_entity)) { /* In this mode the tag and parent components are not |