diff options
Diffstat (limited to 'gcc/ada/gcc-interface')
-rw-r--r-- | gcc/ada/gcc-interface/decl.c | 4 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/trans.c | 30 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/utils.c | 22 |
3 files changed, 35 insertions, 21 deletions
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 2145a47..bf70486 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -4654,7 +4654,9 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ? Non_Limited_View (gnat_entity) : Present (Full_View (gnat_entity)) ? Full_View (gnat_entity) - : Underlying_Full_View (gnat_entity); + : IN (kind, Private_Kind) + ? Underlying_Full_View (gnat_entity) + : Empty; /* If this is an incomplete type with no full view, it must be a Taft Amendment type, in which case we return a dummy type. Otherwise, diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index 1b7d861..64e428a 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -7893,10 +7893,20 @@ process_freeze_entity (Node_Id gnat_node) if (gnu_old) { save_gnu_tree (gnat_entity, NULL_TREE, false); + if (IN (kind, Incomplete_Or_Private_Kind) - && Present (Full_View (gnat_entity)) - && present_gnu_tree (Full_View (gnat_entity))) - save_gnu_tree (Full_View (gnat_entity), NULL_TREE, false); + && Present (Full_View (gnat_entity))) + { + Entity_Id full_view = Full_View (gnat_entity); + + if (IN (Ekind (full_view), Private_Kind) + && Present (Underlying_Full_View (full_view))) + full_view = Underlying_Full_View (full_view); + + if (present_gnu_tree (full_view)) + save_gnu_tree (full_view, NULL_TREE, false); + } + if (IN (kind, Type_Kind) && Present (Class_Wide_Type (gnat_entity)) && Root_Type (Class_Wide_Type (gnat_entity)) == gnat_entity) @@ -7906,17 +7916,23 @@ process_freeze_entity (Node_Id gnat_node) if (IN (kind, Incomplete_Or_Private_Kind) && Present (Full_View (gnat_entity))) { - gnu_new = gnat_to_gnu_entity (Full_View (gnat_entity), NULL_TREE, 1); + Entity_Id full_view = Full_View (gnat_entity); + + if (IN (Ekind (full_view), Private_Kind) + && Present (Underlying_Full_View (full_view))) + full_view = Underlying_Full_View (full_view); + + gnu_new = gnat_to_gnu_entity (full_view, NULL_TREE, 1); /* Propagate back-annotations from full view to partial view. */ if (Unknown_Alignment (gnat_entity)) - Set_Alignment (gnat_entity, Alignment (Full_View (gnat_entity))); + Set_Alignment (gnat_entity, Alignment (full_view)); if (Unknown_Esize (gnat_entity)) - Set_Esize (gnat_entity, Esize (Full_View (gnat_entity))); + Set_Esize (gnat_entity, Esize (full_view)); if (Unknown_RM_Size (gnat_entity)) - Set_RM_Size (gnat_entity, RM_Size (Full_View (gnat_entity))); + Set_RM_Size (gnat_entity, RM_Size (full_view)); /* The above call may have defined this entity (the simplest example of this is when we have a private enumeral type since the bounds diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index f450f24..f44bda3 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -328,35 +328,31 @@ present_gnu_tree (Entity_Id gnat_entity) tree make_dummy_type (Entity_Id gnat_type) { - Entity_Id gnat_underlying = Gigi_Equivalent_Type (gnat_type); + Entity_Id gnat_equiv = Gigi_Equivalent_Type (Underlying_Type (gnat_type)); tree gnu_type; - /* If there is an equivalent type, get its underlying type. */ - if (Present (gnat_underlying)) - gnat_underlying = Gigi_Equivalent_Type (Underlying_Type (gnat_underlying)); - /* If there was no equivalent type (can only happen when just annotating types) or underlying type, go back to the original type. */ - if (No (gnat_underlying)) - gnat_underlying = gnat_type; + if (No (gnat_equiv)) + gnat_equiv = gnat_type; /* If it there already a dummy type, use that one. Else make one. */ - if (PRESENT_DUMMY_NODE (gnat_underlying)) - return GET_DUMMY_NODE (gnat_underlying); + if (PRESENT_DUMMY_NODE (gnat_equiv)) + return GET_DUMMY_NODE (gnat_equiv); /* If this is a record, make a RECORD_TYPE or UNION_TYPE; else make an ENUMERAL_TYPE. */ - gnu_type = make_node (Is_Record_Type (gnat_underlying) - ? tree_code_for_record_type (gnat_underlying) + gnu_type = make_node (Is_Record_Type (gnat_equiv) + ? tree_code_for_record_type (gnat_equiv) : ENUMERAL_TYPE); TYPE_NAME (gnu_type) = get_entity_name (gnat_type); TYPE_DUMMY_P (gnu_type) = 1; TYPE_STUB_DECL (gnu_type) = create_type_stub_decl (TYPE_NAME (gnu_type), gnu_type); - if (Is_By_Reference_Type (gnat_underlying)) + if (Is_By_Reference_Type (gnat_equiv)) TYPE_BY_REFERENCE_P (gnu_type) = 1; - SET_DUMMY_NODE (gnat_underlying, gnu_type); + SET_DUMMY_NODE (gnat_equiv, gnu_type); return gnu_type; } |