decl.c (maybe_saturate_size): New function.
* gcc-interface/decl.c (maybe_saturate_size): New function. (gnat_to_gnu_entity): Invoke it on the Esize of types before sending it for back-annotations. * gcc-interface/trans.c: Fix typo. From-SVN: r275200
This commit is contained in:
parent
f76cf133e2
commit
875bdbe2f6
@ -1,3 +1,10 @@
|
||||
2019-08-30 Eric Botcazou <ebotcazou@adacore.com>
|
||||
|
||||
* gcc-interface/decl.c (maybe_saturate_size): New function.
|
||||
(gnat_to_gnu_entity): Invoke it on the Esize of types before sending
|
||||
it for back-annotations.
|
||||
* gcc-interface/trans.c: Fix typo.
|
||||
|
||||
2019-08-30 Eric Botcazou <ebotcazou@adacore.com>
|
||||
|
||||
* gcc-interface/ada-tree.h (DECL_FORCED_BY_REF_P): New macro.
|
||||
|
||||
@ -232,6 +232,7 @@ static tree build_position_list (tree, bool, tree, tree, unsigned int, tree);
|
||||
static vec<subst_pair> build_subst_list (Entity_Id, Entity_Id, bool);
|
||||
static vec<variant_desc> build_variant_list (tree, vec<subst_pair>,
|
||||
vec<variant_desc>);
|
||||
static tree maybe_saturate_size (tree);
|
||||
static tree validate_size (Uint, tree, Entity_Id, enum tree_code, bool, bool);
|
||||
static void set_rm_size (Uint, tree, Entity_Id);
|
||||
static unsigned int validate_alignment (Uint, Entity_Id, unsigned int);
|
||||
@ -4327,9 +4328,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
|
||||
{
|
||||
tree gnu_size = TYPE_SIZE (gnu_type);
|
||||
|
||||
/* If the size is self-referential, annotate the maximum value. */
|
||||
/* If the size is self-referential, annotate the maximum value
|
||||
after saturating it, if need be, to avoid a No_Uint value. */
|
||||
if (CONTAINS_PLACEHOLDER_P (gnu_size))
|
||||
gnu_size = max_size (gnu_size, true);
|
||||
gnu_size = maybe_saturate_size (max_size (gnu_size, true));
|
||||
|
||||
/* If we are just annotating types and the type is tagged, the tag
|
||||
and the parent components are not generated by the front-end so
|
||||
@ -4365,7 +4367,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
|
||||
gnu_size = size_binop (PLUS_EXPR, gnu_size, offset);
|
||||
}
|
||||
|
||||
gnu_size = round_up (gnu_size, align);
|
||||
gnu_size = maybe_saturate_size (round_up (gnu_size, align));
|
||||
Set_Esize (gnat_entity, annotate_value (gnu_size));
|
||||
|
||||
/* Tagged types are Strict_Alignment so RM_Size = Esize. */
|
||||
@ -8723,6 +8725,19 @@ build_variant_list (tree qual_union_type, vec<subst_pair> subst_list,
|
||||
return gnu_list;
|
||||
}
|
||||
|
||||
/* If SIZE has overflowed, return the maximum valid size, which is the upper
|
||||
bound of the signed sizetype in bits; otherwise return SIZE unmodified. */
|
||||
|
||||
static tree
|
||||
maybe_saturate_size (tree size)
|
||||
{
|
||||
if (TREE_CODE (size) == INTEGER_CST && TREE_OVERFLOW (size))
|
||||
size = size_binop (MULT_EXPR,
|
||||
fold_convert (bitsizetype, TYPE_MAX_VALUE (ssizetype)),
|
||||
build_int_cst (bitsizetype, BITS_PER_UNIT));
|
||||
return size;
|
||||
}
|
||||
|
||||
/* UINT_SIZE is a Uint giving the specified size for an object of GNU_TYPE
|
||||
corresponding to GNAT_OBJECT. If the size is valid, return an INTEGER_CST
|
||||
corresponding to its value. Otherwise, return NULL_TREE. KIND is set to
|
||||
@ -10137,7 +10152,7 @@ concat_name (tree gnu_name, const char *suffix)
|
||||
return get_identifier_with_length (new_name, len);
|
||||
}
|
||||
|
||||
/* Initialize data structures of the decl.c module. */
|
||||
/* Initialize the data structures of the decl.c module. */
|
||||
|
||||
void
|
||||
init_gnat_decl (void)
|
||||
@ -10149,7 +10164,7 @@ init_gnat_decl (void)
|
||||
dummy_to_subprog_map = hash_table<dummy_type_hasher>::create_ggc (512);
|
||||
}
|
||||
|
||||
/* Destroy data structures of the decl.c module. */
|
||||
/* Destroy the data structures of the decl.c module. */
|
||||
|
||||
void
|
||||
destroy_gnat_decl (void)
|
||||
|
||||
@ -8790,7 +8790,7 @@ gnat_to_gnu (Node_Id gnat_node)
|
||||
|
||||
5. If this is a reference to an unconstrained array which is used as the
|
||||
prefix of an attribute reference that requires an lvalue, return the
|
||||
result unmodified because we want return the original bounds.
|
||||
result unmodified because we want to return the original bounds.
|
||||
|
||||
6. Finally, if the type of the result is already correct. */
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user