diff options
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/c-family/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/c-family/c-common.c | 7 | ||||
-rw-r--r-- | gcc/tree.c | 8 | ||||
-rw-r--r-- | gcc/tree.h | 1 |
5 files changed, 27 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bf74a0a..3caa28a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2019-02-18 Martin Sebor <msebor@redhat.com> + + PR middle-end/89294 + * tree.c (valid_constant_size_p): Avoid assuming size is a constant + expression. + * tree.h (cst_size_error): Add the cst_size_not_constant enumerator. + 2019-02-18 Richard Biener <rguenther@suse.de> PR tree-optimization/89296 diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index ed8026a..2d3839e 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2019-02-18 Martin Sebor <msebor@redhat.com> + + PR middle-end/89294 + * c-common.c (invalid_array_size_error): Handle cst_size_not_constant. + 2019-02-16 David Malcolm <dmalcolm@redhat.com> PR c++/88680 diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index c6856c9..e5a5ea8 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -8248,6 +8248,13 @@ invalid_array_size_error (location_t loc, cst_size_error error, tree maxsize = max_object_size (); switch (error) { + case cst_size_not_constant: + if (name) + error_at (loc, "size of array %qE is not a constant expression", + name); + else + error_at (loc, "size of array is not a constant expression"); + break; case cst_size_negative: if (name) error_at (loc, "size %qE of array %qE is negative", @@ -7521,7 +7521,13 @@ valid_constant_size_p (const_tree size, cst_size_error *perr /* = NULL */) if (!perr) perr = &error; - if (TREE_OVERFLOW (size)) + if (TREE_CODE (size) != INTEGER_CST) + { + *perr = cst_size_not_constant; + return false; + } + + if (TREE_OVERFLOW_P (size)) { *perr = cst_size_overflow; return false; @@ -4352,6 +4352,7 @@ extern tree excess_precision_type (tree); is not a valid size. */ enum cst_size_error { cst_size_ok, + cst_size_not_constant, cst_size_negative, cst_size_too_big, cst_size_overflow |