From d42b75599229d4a0e36fddae2931feff40ae7c03 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Tue, 21 Jun 2016 21:34:12 +0000 Subject: [PATCH] tree.c (verify_type_variant): Skip TYPE_SIZE and TYPE_SIZE_UNIT if they are both PLACEHOLDER_EXPRs. * tree.c (verify_type_variant): Skip TYPE_SIZE and TYPE_SIZE_UNIT if they are both PLACEHOLDER_EXPRs. ada/ * gcc-interface/decl.c (set_nonaliased_component_on_array_type): New function. (set_reverse_storage_order_on_array_type): Likewise. (gnat_to_gnu_entity) : Call them to set the flags. : Likewise. : Likewise. (substitute_in_type) : Likewise. * gcc-interface/utils.c (gnat_pushdecl): Always create a variant for the DECL_ORIGINAL_TYPE of a type. From-SVN: r237658 --- gcc/ChangeLog | 5 ++++ gcc/ada/ChangeLog | 12 +++++++++ gcc/ada/gcc-interface/decl.c | 48 +++++++++++++++++++++++++---------- gcc/ada/gcc-interface/utils.c | 15 +---------- gcc/tree.c | 8 ++++-- 5 files changed, 59 insertions(+), 29 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 627de2bfdcb..ff7bf8f8674 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2016-06-21 Eric Botcazou + + * tree.c (verify_type_variant): Skip TYPE_SIZE and TYPE_SIZE_UNIT if + they are both PLACEHOLDER_EXPRs. + 2016-06-21 Michael Meissner * stor-layout.c (layout_type): Move setting complex MODE to diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 4987a23808f..1d605212934 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,15 @@ +2016-06-21 Eric Botcazou + + * gcc-interface/decl.c (set_nonaliased_component_on_array_type): New + function. + (set_reverse_storage_order_on_array_type): Likewise. + (gnat_to_gnu_entity) : Call them to set the flags. + : Likewise. + : Likewise. + (substitute_in_type) : Likewise. + * gcc-interface/utils.c (gnat_pushdecl): Always create a variant for + the DECL_ORIGINAL_TYPE of a type. + 2016-06-20 Hristian Kirtchev * make.adb, gnatbind.adb, g-socket.adb, sem_ch13.adb: Minor diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 0ce2d47f195..96f48419128 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -206,6 +206,8 @@ static tree gnat_to_gnu_subprog_type (Entity_Id, bool, bool, tree *); static tree gnat_to_gnu_field (Entity_Id, tree, int, bool, bool); static tree gnu_ext_name_for_subprog (Entity_Id, tree); static tree change_qualified_type (tree, int); +static void set_nonaliased_component_on_array_type (tree); +static void set_reverse_storage_order_on_array_type (tree); static bool same_discriminant_p (Entity_Id, Entity_Id); static bool array_type_has_nonaliased_component (tree, Entity_Id); static bool compile_time_known_address_p (Node_Id); @@ -2265,12 +2267,12 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) for (index = ndim - 1; index >= 0; index--) { tem = build_nonshared_array_type (tem, gnu_index_types[index]); - if (index == ndim - 1) - TYPE_REVERSE_STORAGE_ORDER (tem) - = Reverse_Storage_Order (gnat_entity); TYPE_MULTI_ARRAY_P (tem) = (index > 0); + TYPE_CONVENTION_FORTRAN_P (tem) = convention_fortran_p; + if (index == ndim - 1 && Reverse_Storage_Order (gnat_entity)) + set_reverse_storage_order_on_array_type (tem); if (array_type_has_nonaliased_component (tem, gnat_entity)) - TYPE_NONALIASED_COMPONENT (tem) = 1; + set_nonaliased_component_on_array_type (tem); } /* If an alignment is specified, use it if valid. But ignore it @@ -2287,8 +2289,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) TYPE_USER_ALIGN (tem) = 1; } - TYPE_CONVENTION_FORTRAN_P (tem) = convention_fortran_p; - /* Tag top-level ARRAY_TYPE nodes for packed arrays and their implementation types as such so that the debug information back-end can output the appropriate description for them. */ @@ -2651,12 +2651,12 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) { gnu_type = build_nonshared_array_type (gnu_type, gnu_index_types[index]); - if (index == ndim - 1) - TYPE_REVERSE_STORAGE_ORDER (gnu_type) - = Reverse_Storage_Order (gnat_entity); TYPE_MULTI_ARRAY_P (gnu_type) = (index > 0); + TYPE_CONVENTION_FORTRAN_P (gnu_type) = convention_fortran_p; + if (index == ndim - 1 && Reverse_Storage_Order (gnat_entity)) + set_reverse_storage_order_on_array_type (gnu_type); if (array_type_has_nonaliased_component (gnu_type, gnat_entity)) - TYPE_NONALIASED_COMPONENT (gnu_type) = 1; + set_nonaliased_component_on_array_type (gnu_type); } /* Strip the ___XP suffix for standard DWARF. */ @@ -2764,7 +2764,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) } } - TYPE_CONVENTION_FORTRAN_P (gnu_type) = convention_fortran_p; TYPE_PACKED_ARRAY_TYPE_P (gnu_type) = (Is_Packed_Array_Impl_Type (gnat_entity) && Is_Bit_Packed_Array (Original_Array_Type (gnat_entity))); @@ -2932,7 +2931,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) (Component_Type (gnat_entity)), gnu_index_type); if (array_type_has_nonaliased_component (gnu_type, gnat_entity)) - TYPE_NONALIASED_COMPONENT (gnu_type) = 1; + set_nonaliased_component_on_array_type (gnu_type); relate_alias_sets (gnu_type, gnu_string_type, ALIAS_SET_COPY); } break; @@ -6223,6 +6222,26 @@ change_qualified_type (tree type, int type_quals) return build_qualified_type (type, TYPE_QUALS (type) | type_quals); } +/* Set TYPE_NONALIASED_COMPONENT on an array type built by means of + build_nonshared_array_type. */ + +static void +set_nonaliased_component_on_array_type (tree type) +{ + TYPE_NONALIASED_COMPONENT (type) = 1; + TYPE_NONALIASED_COMPONENT (TYPE_CANONICAL (type)) = 1; +} + +/* Set TYPE_REVERSE_STORAGE_ORDER on an array type built by means of + build_nonshared_array_type. */ + +static void +set_reverse_storage_order_on_array_type (tree type) +{ + TYPE_REVERSE_STORAGE_ORDER (type) = 1; + TYPE_REVERSE_STORAGE_ORDER (TYPE_CANONICAL (type)) = 1; +} + /* Return true if DISCR1 and DISCR2 represent the same discriminant. */ static bool @@ -9262,9 +9281,12 @@ substitute_in_type (tree t, tree f, tree r) SET_TYPE_MODE (nt, TYPE_MODE (t)); TYPE_SIZE (nt) = SUBSTITUTE_IN_EXPR (TYPE_SIZE (t), f, r); TYPE_SIZE_UNIT (nt) = SUBSTITUTE_IN_EXPR (TYPE_SIZE_UNIT (t), f, r); - TYPE_NONALIASED_COMPONENT (nt) = TYPE_NONALIASED_COMPONENT (t); TYPE_MULTI_ARRAY_P (nt) = TYPE_MULTI_ARRAY_P (t); TYPE_CONVENTION_FORTRAN_P (nt) = TYPE_CONVENTION_FORTRAN_P (t); + if (TYPE_REVERSE_STORAGE_ORDER (t)) + set_reverse_storage_order_on_array_type (nt); + if (TYPE_NONALIASED_COMPONENT (t)) + set_nonaliased_component_on_array_type (nt); return nt; } diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index 1f1e4d3b814..8e4f8638258 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -789,24 +789,11 @@ gnat_pushdecl (tree decl, Node_Id gnat_node) || TREE_CODE (t) == POINTER_TYPE || TYPE_IS_FAT_POINTER_P (t))) { - tree tt; - /* ??? Copy and original type are not supposed to be variant but we - really need a variant for the placeholder machinery to work. */ - if (TYPE_IS_FAT_POINTER_P (t)) - tt = build_variant_type_copy (t); - else - { - /* TYPE_NEXT_PTR_TO is a chain of main variants. */ - tt = build_distinct_type_copy (TYPE_MAIN_VARIANT (t)); - if (TREE_CODE (t) == POINTER_TYPE) - TYPE_NEXT_PTR_TO (TYPE_MAIN_VARIANT (t)) = tt; - tt = build_qualified_type (tt, TYPE_QUALS (t)); - } + tree tt = build_variant_type_copy (t); TYPE_NAME (tt) = decl; defer_or_set_type_context (tt, DECL_CONTEXT (decl), deferred_decl_context); - TREE_USED (tt) = TREE_USED (t); TREE_TYPE (decl) = tt; if (TYPE_NAME (t) && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL diff --git a/gcc/tree.c b/gcc/tree.c index 58c663a8220..bc60190b339 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -13220,9 +13220,13 @@ verify_type_variant (const_tree t, tree tv) if (COMPLETE_TYPE_P (t)) { - verify_variant_match (TYPE_SIZE); verify_variant_match (TYPE_MODE); - if (TYPE_SIZE_UNIT (t) != TYPE_SIZE_UNIT (tv) + if (TREE_CODE (TYPE_SIZE (t)) != PLACEHOLDER_EXPR + && TREE_CODE (TYPE_SIZE (tv)) != PLACEHOLDER_EXPR) + verify_variant_match (TYPE_SIZE); + if (TREE_CODE (TYPE_SIZE_UNIT (t)) != PLACEHOLDER_EXPR + && TREE_CODE (TYPE_SIZE_UNIT (tv)) != PLACEHOLDER_EXPR + && TYPE_SIZE_UNIT (t) != TYPE_SIZE_UNIT (tv) /* FIXME: ideally we should compare pointer equality, but java FE produce variants where size is INTEGER_CST of different type (int wrt size_type) during libjava biuld. */ -- 2.30.2