diff options
author | Marek Polacek <polacek@redhat.com> | 2015-11-11 14:47:03 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2015-11-11 14:47:03 +0000 |
commit | e78bede6f774bc0d294adafe5e3367c4da10647e (patch) | |
tree | 48b3e7d70614879dd48b43b013beb7831d9ad8ba /gcc/c | |
parent | a5b50aa1fb086c90dd0119f8cb9e0a88ea9cce58 (diff) | |
download | gcc-e78bede6f774bc0d294adafe5e3367c4da10647e.zip gcc-e78bede6f774bc0d294adafe5e3367c4da10647e.tar.gz gcc-e78bede6f774bc0d294adafe5e3367c4da10647e.tar.bz2 |
re PR c/68107 (Non-VLA type whose size is half or more of the address space constructed via a pointer)
PR c/68107
PR c++/68266
* c-common.c (valid_array_size_p): New function.
* c-common.h (valid_array_size_p): Declare.
* c-decl.c (grokdeclarator): Call valid_array_size_p. Remove code
checking the size of an array.
* decl.c (grokdeclarator): Call valid_array_size_p. Remove code
checking the size of an array.
* c-c++-common/pr68107.c: New test.
* g++.dg/init/new38.C (large_array_char): Adjust dg-error.
(large_array_char_template): Likewise.
* g++.dg/init/new44.C: Adjust dg-error.
From-SVN: r230174
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/c/c-decl.c | 22 |
2 files changed, 12 insertions, 17 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 8fb3786..87f6a2d 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,10 @@ +2015-11-11 Marek Polacek <polacek@redhat.com> + + PR c/68107 + PR c++/68266 + * c-decl.c (grokdeclarator): Call valid_array_size_p. Remove code + checking the size of an array. + 2015-11-11 Andrew MacLeod <amacleod@redhat.com> * c-array-notation.c: Remove unused header files. diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index c58dec6..a636474 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -6000,6 +6000,9 @@ grokdeclarator (const struct c_declarator *declarator, TYPE_SIZE_UNIT (type) = size_zero_node; SET_TYPE_STRUCTURAL_EQUALITY (type); } + + if (!valid_array_size_p (loc, type, name)) + type = error_mark_node; } if (decl_context != PARM @@ -6007,7 +6010,8 @@ grokdeclarator (const struct c_declarator *declarator, || array_ptr_attrs != NULL_TREE || array_parm_static)) { - error_at (loc, "static or type qualifiers in non-parameter array declarator"); + error_at (loc, "static or type qualifiers in non-parameter " + "array declarator"); array_ptr_quals = TYPE_UNQUALIFIED; array_ptr_attrs = NULL_TREE; array_parm_static = 0; @@ -6286,22 +6290,6 @@ grokdeclarator (const struct c_declarator *declarator, } } - /* Did array size calculations overflow or does the array cover more - than half of the address-space? */ - if (TREE_CODE (type) == ARRAY_TYPE - && COMPLETE_TYPE_P (type) - && TREE_CODE (TYPE_SIZE_UNIT (type)) == INTEGER_CST - && ! valid_constant_size_p (TYPE_SIZE_UNIT (type))) - { - if (name) - error_at (loc, "size of array %qE is too large", name); - else - error_at (loc, "size of unnamed array is too large"); - /* If we proceed with the array type as it is, we'll eventually - crash in tree_to_[su]hwi(). */ - type = error_mark_node; - } - /* If this is declaring a typedef name, return a TYPE_DECL. */ if (storage_class == csc_typedef) |