aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorWill Cohen <wcohen@redhat.com>2000-10-04 18:03:33 +0000
committerWilliam Cohen <wcohen@gcc.gnu.org>2000-10-04 18:03:33 +0000
commit4b606faf44b11ba1155388afca7abfd5e922b023 (patch)
tree50adc28a80efb5aff96a5d508de8bc7cc9824c02 /gcc
parent3a4fee6674b8b7a3ece873a3ac19fa2fea41bf8e (diff)
downloadgcc-4b606faf44b11ba1155388afca7abfd5e922b023.zip
gcc-4b606faf44b11ba1155388afca7abfd5e922b023.tar.gz
gcc-4b606faf44b11ba1155388afca7abfd5e922b023.tar.bz2
Patched code to generate warning when trying to perform static
initialization of zero-length arrays. From-SVN: r36714
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog19
-rw-r--r--gcc/c-typeck.c3
-rw-r--r--gcc/extend.texi4
3 files changed, 14 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 405b691..eede1ca 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2000-10-04 Will Cohen <wcohen@redhat.com>
+
+ * c-typeck.c (process_init_element): Added warning for zero-length
+ array.
+
+ * extend.texi (Zero Length): State that static initializers for
+ zero-length arrays are not allowed.
+
Mon Oct 2 14:50:14 MET DST 2000 Jan Hubicka <jh@suse.cz>
* rtlanal.c (single_set_1): Do not require USE and CLOBBERs
@@ -1139,17 +1147,6 @@ Mon 18-Sep-2000 19:21:35 BST Neil Booth <NeilB@earthling.net>
* config/sh/sh.md (sym_label2reg, symPLT_label2reg): Protect
LABEL_REFs with a PIC-safe unspec.
-2000-09-18 Will Cohen <wcohen@redhat.com>
-
- * extend.texi (Zero Length): State that static initializers for
- zero-length arrays are not allowed.
-
- * c-typeck.c (process_init_element): Flag initializers for zero
- length arrays.
-
- * tree.c (integer_all_onesp): Ignore TREE_INT_CST_HIGH if prec is
- exactly HOST_BITS_PERWIDE_INT.
-
2000-09-18 Joseph S. Myers <jsm28@cam.ac.uk>
* c-common.c (check_format_info): Properly save the argument
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index da8ced2..9f2ec8d 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -6460,7 +6460,8 @@ process_init_element (value)
}
if (constructor_max_index != 0
- && tree_int_cst_lt (constructor_max_index, constructor_index))
+ && (tree_int_cst_lt (constructor_max_index, constructor_index)
+ || integer_all_onesp (constructor_max_index)))
{
pedwarn_init ("excess elements in array initializer");
break;
diff --git a/gcc/extend.texi b/gcc/extend.texi
index 40e57b3..2c6b4d1 100644
--- a/gcc/extend.texi
+++ b/gcc/extend.texi
@@ -889,6 +889,10 @@ struct line @{
In standard C, you would have to give @code{contents} a length of 1, which
means either you waste space or complicate the argument to @code{malloc}.
+Static initialization of the zero-length array is not allowed. A
+warning will be generated for each initializer attempting to initialize
+the zero-length array.
+
@node Variable Length
@section Arrays of Variable Length
@cindex variable-length arrays