aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-02-26 22:27:33 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2019-02-26 22:27:33 +0100
commit8735903781aabdb48683d24d783eba6c76fd8c99 (patch)
tree7bdb2c7cc9100224603610317f3e4551bef40e1c /gcc/tree.c
parent1405bf4c9c5324639ca4b0a6529b5e4a43eb31db (diff)
downloadgcc-8735903781aabdb48683d24d783eba6c76fd8c99.zip
gcc-8735903781aabdb48683d24d783eba6c76fd8c99.tar.gz
gcc-8735903781aabdb48683d24d783eba6c76fd8c99.tar.bz2
re PR c++/89507 (bogus "size of array exceeds maximum object size")
PR c++/89507 * tree.c (valid_constant_size_p): Deal with size INTEGER_CSTs with types other than sizetype/ssizetype. * g++.dg/other/new2.C: New test. From-SVN: r269233
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 30e01df..0c70bb9 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -7533,19 +7533,16 @@ valid_constant_size_p (const_tree size, cst_size_error *perr /* = NULL */)
return false;
}
- tree type = TREE_TYPE (size);
- if (TYPE_UNSIGNED (type))
+ if (tree_int_cst_sgn (size) < 0)
{
- if (!tree_fits_uhwi_p (size)
- || tree_int_cst_sign_bit (size))
- {
- *perr = cst_size_too_big;
- return false;
- }
+ *perr = cst_size_negative;
+ return false;
}
- else if (tree_int_cst_sign_bit (size))
+ if (!tree_fits_uhwi_p (size)
+ || (wi::to_widest (TYPE_MAX_VALUE (sizetype))
+ < wi::to_widest (size) * 2))
{
- *perr = cst_size_negative;
+ *perr = cst_size_too_big;
return false;
}