diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2019-08-30 15:32:51 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2019-08-30 15:32:51 +0000 |
commit | 875bdbe2f6d2d54f0ccefd27cea3a533fef834eb (patch) | |
tree | 9a2afaa36f69c5a449b22f5fa5b624fe3824adb2 /gcc/ada | |
parent | f76cf133e283a99c8b39fb52c4a27fbac59b4c66 (diff) | |
download | gcc-875bdbe2f6d2d54f0ccefd27cea3a533fef834eb.zip gcc-875bdbe2f6d2d54f0ccefd27cea3a533fef834eb.tar.gz gcc-875bdbe2f6d2d54f0ccefd27cea3a533fef834eb.tar.bz2 |
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
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/decl.c | 25 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/trans.c | 2 |
3 files changed, 28 insertions, 6 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index bb43565..410828e 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,5 +1,12 @@ 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. * gcc-interface/decl.c (gnat_to_gnu_param): Set it on parameters whose mechanism was forced to by-reference. diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 85a5e76..d1082ee 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -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) diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index 4d2fa93..fe02dc4 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -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. */ |