diff options
Diffstat (limited to 'gcc/ada/gcc-interface/decl.c')
-rw-r--r-- | gcc/ada/gcc-interface/decl.c | 78 |
1 files changed, 37 insertions, 41 deletions
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index b5ee0cf..9ca27fd 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -207,8 +207,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) /* True if we made GNU_DECL and its type here. */ bool this_made_decl = false; /* True if debug info is requested for this entity. */ - bool debug_info_p = (Needs_Debug_Info (gnat_entity) - || debug_info_level == DINFO_LEVEL_VERBOSE); + bool debug_info_p = Needs_Debug_Info (gnat_entity); /* True if this entity is to be considered as imported. */ bool imported_p = (Is_Imported (gnat_entity) && No (Address_Clause (gnat_entity))); @@ -983,8 +982,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) as we have a VAR_DECL for the pointer we make. */ } - gnu_expr - = build_unary_op (ADDR_EXPR, gnu_type, maybe_stable_expr); + gnu_expr = build_unary_op (ADDR_EXPR, gnu_type, + maybe_stable_expr); gnu_size = NULL_TREE; used_by_ref = true; @@ -1291,10 +1290,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) || Is_Exported (gnat_entity))))) gnu_ext_name = create_concat_name (gnat_entity, NULL); - /* If this is constant initialized to a static constant and the - object has an aggregate type, force it to be statically - allocated. This will avoid an initialization copy. */ - if (!static_p && const_flag + /* If this is an aggregate constant initialized to a constant, force it + to be statically allocated. This saves an initialization copy. */ + if (!static_p + && const_flag && gnu_expr && TREE_CONSTANT (gnu_expr) && AGGREGATE_TYPE_P (gnu_type) && host_integerp (TYPE_SIZE_UNIT (gnu_type), 1) @@ -1303,11 +1302,11 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) (TREE_TYPE (TYPE_FIELDS (gnu_type))), 1))) static_p = true; - gnu_decl = create_var_decl (gnu_entity_name, gnu_ext_name, gnu_type, - gnu_expr, const_flag, - Is_Public (gnat_entity), - imported_p || !definition, - static_p, attr_list, gnat_entity); + gnu_decl + = create_var_decl (gnu_entity_name, gnu_ext_name, gnu_type, + gnu_expr, const_flag, Is_Public (gnat_entity), + imported_p || !definition, static_p, attr_list, + gnat_entity); DECL_BY_REF_P (gnu_decl) = used_by_ref; DECL_POINTS_TO_READONLY_P (gnu_decl) = used_by_ref && inner_const_flag; if (TREE_CODE (gnu_decl) == VAR_DECL && renamed_obj) @@ -3473,7 +3472,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) SET_TYPE_UNCONSTRAINED_ARRAY (gnu_type, gnu_old); TYPE_POINTER_TO (gnu_old) = gnu_type; - Sloc_to_locus (Sloc (gnat_entity), &input_location); fields = chainon (chainon (NULL_TREE, create_field_decl @@ -4170,8 +4168,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) | (TYPE_QUAL_CONST * const_flag) | (TYPE_QUAL_VOLATILE * volatile_flag)); - Sloc_to_locus (Sloc (gnat_entity), &input_location); - if (has_stub) gnu_stub_type = build_qualified_type (gnu_stub_type, @@ -4705,38 +4701,40 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) if (Unknown_Esize (gnat_entity) && TYPE_SIZE (gnu_type)) { - /* If the size is self-referential, we annotate the maximum - value of that size. */ tree gnu_size = TYPE_SIZE (gnu_type); + /* If the size is self-referential, annotate the maximum value. */ if (CONTAINS_PLACEHOLDER_P (gnu_size)) gnu_size = max_size (gnu_size, true); - Set_Esize (gnat_entity, annotate_value (gnu_size)); - if (type_annotate_only && Is_Tagged_Type (gnat_entity)) { - /* In this mode the tag and the parent components are not - generated by the front-end, so the sizes must be adjusted - explicitly now. */ - int size_offset, new_size; + /* In this mode, the tag and the parent components are not + generated by the front-end so the sizes must be adjusted. */ + tree pointer_size = bitsize_int (POINTER_SIZE), offset; + Uint uint_size; if (Is_Derived_Type (gnat_entity)) { - size_offset - = UI_To_Int (Esize (Etype (Base_Type (gnat_entity)))); + offset = UI_To_gnu (Esize (Etype (Base_Type (gnat_entity))), + bitsizetype); Set_Alignment (gnat_entity, Alignment (Etype (Base_Type (gnat_entity)))); } else - size_offset = POINTER_SIZE; - - new_size = UI_To_Int (Esize (gnat_entity)) + size_offset; - Set_Esize (gnat_entity, - UI_From_Int (((new_size + (POINTER_SIZE - 1)) - / POINTER_SIZE) * POINTER_SIZE)); - Set_RM_Size (gnat_entity, Esize (gnat_entity)); + offset = pointer_size; + + gnu_size = size_binop (PLUS_EXPR, gnu_size, offset); + gnu_size = size_binop (MULT_EXPR, pointer_size, + size_binop (CEIL_DIV_EXPR, + gnu_size, + pointer_size)); + uint_size = annotate_value (gnu_size); + Set_Esize (gnat_entity, uint_size); + Set_RM_Size (gnat_entity, uint_size); } + else + Set_Esize (gnat_entity, annotate_value (gnu_size)); } if (Unknown_RM_Size (gnat_entity) && rm_size (gnu_type)) @@ -5366,15 +5364,14 @@ compile_time_known_address_p (Node_Id gnat_address) return Compile_Time_Known_Value (gnat_address); } -/* Return true if GNAT_RANGE, a N_Range node, cannot be superflat, i.e. - cannot verify HB < LB-1 when LB and HB are the low and high bounds. */ +/* Return true if GNAT_RANGE, a N_Range node, cannot be superflat, i.e. if the + inequality HB >= LB-1 is true. LB and HB are the low and high bounds. */ static bool cannot_be_superflat_p (Node_Id gnat_range) { Node_Id gnat_lb = Low_Bound (gnat_range), gnat_hb = High_Bound (gnat_range); Node_Id scalar_range; - tree gnu_lb, gnu_hb; /* If the low bound is not constant, try to find an upper bound. */ @@ -7087,12 +7084,10 @@ components_to_record (tree gnu_record_type, Node_Id gnat_component_list, static Uint annotate_value (tree gnu_size) { - int len = TREE_CODE_LENGTH (TREE_CODE (gnu_size)); TCode tcode; Node_Ref_Or_Val ops[3], ret; - int i; - int size; struct tree_int_map **h = NULL; + int size, i; /* See if we've already saved the value for this node. */ if (EXPR_P (gnu_size)) @@ -7223,7 +7218,7 @@ annotate_value (tree gnu_size) for (i = 0; i < 3; i++) ops[i] = No_Uint; - for (i = 0; i < len; i++) + for (i = 0; i < TREE_CODE_LENGTH (TREE_CODE (gnu_size)); i++) { ops[i] = annotate_value (TREE_OPERAND (gnu_size, i)); if (ops[i] == No_Uint) @@ -7675,7 +7670,8 @@ set_rm_size (Uint uint_size, tree gnu_type, Entity_Id gnat_entity) && TYPE_PACKED_ARRAY_TYPE_P (gnu_type)) && !(TYPE_IS_PADDING_P (gnu_type) && TREE_CODE (TREE_TYPE (TYPE_FIELDS (gnu_type))) == ARRAY_TYPE - && TYPE_PACKED_ARRAY_TYPE_P (TREE_TYPE (TYPE_FIELDS (gnu_type)))) + && TYPE_PACKED_ARRAY_TYPE_P + (TREE_TYPE (TYPE_FIELDS (gnu_type)))) && tree_int_cst_lt (size, old_size))) { if (Present (gnat_attr_node)) |