This is the mail archive of the
mailing list for the GCC project.
Re: Patch to warn about static initializers for zero length arrays
- To: Will Cohen <wcohen at redhat dot com>
- Subject: Re: Patch to warn about static initializers for zero length arrays
- From: Jeffrey A Law <law at cygnus dot com>
- Date: Mon, 18 Sep 2000 10:27:18 -0600
- cc: gcc-patches at gcc dot gnu dot org
- Reply-To: law at cygnus dot com
In message <39C633EC.81E9FDD5@redhat.com>you write:
> This is a multi-part message in MIME format.
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
> The following patch makes gcc print warnings for initializers of
> zero length arrays as excess initializers. This moves gcc toward
> conforming with the C99 standard on flexible arrays (18.104.22.168).
> * 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.
Thanks. Please install this patch.
> I have also attached a file, zerolength.c, which demonstrates gcc
> warning about the initializer. Assuming that the patch is installed
> the following messages should be generated:
If you could add this to the gcc.dg testing framework it would be
greatly appreciated. You should be able to find examples of how to test
for error messages by looking at other tests in that framework.