diff options
Diffstat (limited to 'gcc/ada/gcc-interface/decl.c')
-rw-r--r-- | gcc/ada/gcc-interface/decl.c | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 3fb7c807614..f2f0f159abd 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -3212,13 +3212,14 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) /* Fill in locations of fields. */ annotate_rep (gnat_entity, gnu_type); - /* We've built a new type, make an XVS type to show what this - is a subtype of. Some debuggers require the XVS type to be - output first, so do it in that order. */ + /* If debugging information is being written for the type, write + a record that shows what we are a subtype of and also make a + variable that indicates our size, if still variable. */ if (debug_info_p) { tree gnu_subtype_marker = make_node (RECORD_TYPE); tree gnu_unpad_base_name = TYPE_NAME (gnu_unpad_base_type); + tree gnu_size_unit = TYPE_SIZE_UNIT (gnu_type); if (TREE_CODE (gnu_unpad_base_name) == TYPE_DECL) gnu_unpad_base_name = DECL_NAME (gnu_unpad_base_name); @@ -3236,6 +3237,13 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) add_parallel_type (TYPE_STUB_DECL (gnu_type), gnu_subtype_marker); + + if (definition + && TREE_CODE (gnu_size_unit) != INTEGER_CST + && !CONTAINS_PLACEHOLDER_P (gnu_size_unit)) + create_var_decl (create_concat_name (gnat_entity, "XVZ"), + NULL_TREE, sizetype, gnu_size_unit, false, + false, false, false, NULL, gnat_entity); } /* Now we can finalize it. */ @@ -4990,6 +4998,17 @@ gnat_to_gnu_component_type (Entity_Id gnat_array, bool definition, Is_Bit_Packed_Array (gnat_array) ? TYPE_DECL : VAR_DECL, true, Has_Component_Size_Clause (gnat_array)); + /* If the array has aliased components and the component size can be zero, + force at least unit size to ensure that the components have distinct + addresses. */ + if (!gnu_comp_size + && Has_Aliased_Components (gnat_array) + && (integer_zerop (TYPE_SIZE (gnu_type)) + || (TREE_CODE (gnu_type) == ARRAY_TYPE + && !TREE_CONSTANT (TYPE_SIZE (gnu_type))))) + gnu_comp_size + = size_binop (MAX_EXPR, TYPE_SIZE (gnu_type), bitsize_unit_node); + /* If the component type is a RECORD_TYPE that has a self-referential size, then use the maximum size for the component size. */ if (!gnu_comp_size @@ -6190,7 +6209,7 @@ maybe_pad_type (tree type, tree size, unsigned int align, add_parallel_type (TYPE_STUB_DECL (record), marker); - if (size && TREE_CODE (size) != INTEGER_CST && definition) + if (definition && size && TREE_CODE (size) != INTEGER_CST) create_var_decl (concat_name (name, "XVZ"), NULL_TREE, sizetype, TYPE_SIZE_UNIT (record), false, false, false, false, NULL, gnat_entity); @@ -6210,6 +6229,7 @@ maybe_pad_type (tree type, tree size, unsigned int align, if (Present (gnat_entity) && size + && TREE_CODE (size) != MAX_EXPR && !operand_equal_p (size, orig_size, 0) && !(TREE_CODE (size) == INTEGER_CST && TREE_CODE (orig_size) == INTEGER_CST @@ -7856,6 +7876,11 @@ check_ok_for_atomic (tree object, Entity_Id gnat_entity, bool comp_p) OBJECT is either a type or a decl. */ if (TYPE_P (object)) { + /* If this is an anonymous base type, nothing to check. Error will be + reported on the source type. */ + if (!Comes_From_Source (gnat_entity)) + return; + mode = TYPE_MODE (object); align = TYPE_ALIGN (object); size = TYPE_SIZE (object); |