aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c46
1 files changed, 40 insertions, 6 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index b8be295..af7abd8 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -7500,10 +7500,12 @@ compare_tree_int (const_tree t, unsigned HOST_WIDE_INT u)
/* Return true if SIZE represents a constant size that is in bounds of
what the middle-end and the backend accepts (covering not more than
- half of the address-space). */
+ half of the address-space).
+ When PERR is non-null, set *PERR on failure to the description of
+ why SIZE is not valid. */
bool
-valid_constant_size_p (const_tree size)
+valid_constant_size_p (const_tree size, cst_size_error *perr /* = NULL */)
{
if (POLY_INT_CST_P (size))
{
@@ -7514,10 +7516,33 @@ valid_constant_size_p (const_tree size)
return false;
return true;
}
- if (! tree_fits_uhwi_p (size)
- || TREE_OVERFLOW (size)
- || tree_int_cst_sign_bit (size) != 0)
- return false;
+
+ cst_size_error error;
+ if (!perr)
+ perr = &error;
+
+ if (TREE_OVERFLOW (size))
+ {
+ *perr = cst_size_overflow;
+ return false;
+ }
+
+ tree type = TREE_TYPE (size);
+ if (TYPE_UNSIGNED (type))
+ {
+ if (!tree_fits_uhwi_p (size)
+ || tree_int_cst_sign_bit (size))
+ {
+ *perr = cst_size_too_big;
+ return false;
+ }
+ }
+ else if (tree_int_cst_sign_bit (size))
+ {
+ *perr = cst_size_negative;
+ return false;
+ }
+
return true;
}
@@ -15003,6 +15028,15 @@ const builtin_structptr_type builtin_structptr_types[6] =
{ const_fexcept_t_ptr_type_node, const_ptr_type_node, "fexcept_t" }
};
+/* Return the maximum object size. */
+
+tree
+max_object_size (void)
+{
+ /* To do: Make this a configurable parameter. */
+ return TYPE_MAX_VALUE (ptrdiff_type_node);
+}
+
#if CHECKING_P
namespace selftest {