diff options
| author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-03-09 17:03:34 +0000 |
|---|---|---|
| committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-03-09 17:03:34 +0000 |
| commit | 983bd96f4b6f26eae4b5e7b0aeaf012ef8c03e71 (patch) | |
| tree | 8eb378f345a71c8ed7a59ad7a085cd3bd7b2144c | |
| parent | edaaa3ffd8e64879111cef58c0471569939e8793 (diff) | |
| download | ppe42-gcc-983bd96f4b6f26eae4b5e7b0aeaf012ef8c03e71.tar.gz ppe42-gcc-983bd96f4b6f26eae4b5e7b0aeaf012ef8c03e71.zip | |
2005-03-09 Paolo Carlini <pcarlini@suse.de>
PR c++/16859
* decl.c (complete_array_type): In pedantic mode, return
3 for an empty initializer list as the initializer for an
array of unknown bound (8.5.1/4).
(maybe_deduce_size_from_array_init): Fix final test to use
the above.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@96194 138bc75d-0d04-0410-961f-82ee72b054a4
| -rw-r--r-- | gcc/cp/ChangeLog | 9 | ||||
| -rw-r--r-- | gcc/cp/decl.c | 10 |
2 files changed, 15 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8eec1963d46..7986946e3e2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2005-03-09 Paolo Carlini <pcarlini@suse.de> + + PR c++/16859 + * decl.c (complete_array_type): In pedantic mode, return + 3 for an empty initializer list as the initializer for an + array of unknown bound (8.5.1/4). + (maybe_deduce_size_from_array_init): Fix final test to use + the above. + 2005-03-08 Nathan Sidwell <nathan@codesourcery.com> PR c++/20186 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index fbb264e9640..c253028709a 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -3924,9 +3924,7 @@ maybe_deduce_size_from_array_init (tree decl, tree init) DECL_EXTERNAL (decl) = 1; } - if (pedantic && TYPE_DOMAIN (type) != NULL_TREE - && tree_int_cst_lt (TYPE_MAX_VALUE (TYPE_DOMAIN (type)), - integer_zero_node)) + if (failure == 3) error ("zero-size array %qD", decl); layout_decl (decl, 0); @@ -5329,7 +5327,8 @@ expand_static_init (tree decl, tree init) /* Make TYPE a complete type based on INITIAL_VALUE. Return 0 if successful, 1 if INITIAL_VALUE can't be deciphered, - 2 if there was no information (in which case assume 0 if DO_DEFAULT). */ + 2 if there was no information (in which case assume 0 if DO_DEFAULT), + 3 if the initializer list is empty (in pedantic mode). */ int complete_array_type (tree type, tree initial_value, int do_default) @@ -5371,6 +5370,9 @@ complete_array_type (tree type, tree initial_value, int do_default) else maxindex = size_binop (PLUS_EXPR, maxindex, ssize_int (1)); } + + if (pedantic && tree_int_cst_equal (maxindex, ssize_int (-1))) + value = 3; } else { |

