OSDN Git Service

Patched code to generate warning when trying to perform static
authorwcohen <wcohen@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 4 Oct 2000 18:03:33 +0000 (18:03 +0000)
committerwcohen <wcohen@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 4 Oct 2000 18:03:33 +0000 (18:03 +0000)
initialization of zero-length arrays.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@36714 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/c-typeck.c
gcc/extend.texi

index 405b691..eede1ca 100644 (file)
@@ -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
index da8ced2..9f2ec8d 100644 (file)
@@ -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;
index 40e57b3..2c6b4d1 100644 (file)
@@ -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