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);
{
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
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. */
return gnu_list;
}
\f
+/* 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
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)
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)