This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix bugs in C99 designated initializers
- To: Jakub Jelinek <jakub at redhat dot com>
- Subject: Re: [PATCH] Fix bugs in C99 designated initializers
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- Date: Fri, 1 Dec 2000 19:30:52 +0000 (GMT)
- cc: <gcc-patches at gcc dot gnu dot org>
On Fri, 1 Dec 2000, Jakub Jelinek wrote:
> This patch fixes a couple of bugs I found in the designated initializers
> support. E.g. C99 designator lists were supported basically in c-parse.in
While fixing bugs in designated initializers you might wish to look also
at gcc.c-torture/execute/20000801-3.c (PR c/92) which is a bug involving
them.
> What is not solved yet is that once we emit some part of array/structure, we
> cannot write back (I think this has been discussed here already).
c99status.html should be updated to describe what cases still don't work
after this patch - then to mark designated initializers Done when they
work fully.
> I'm also not sure whether overwriting of already initialized fields should
> be allowed in C90. This patch allows it in -std=c99 resp. -std=gnu99 only,
I see little reason why it should not be allowed in C90 mode; there are
already appropriate pedwarns in c-parse.in for using designated
initializers at all.
I think there should be a warning when overriding an initializer with side
effects (when it is unspecified whether the side effects of the overridden
initializer occur, DR#208). (Plus, of course, a test for this warning.
And documenting what GCC does in this case, if predictable, along with a
warning not to rely on it, would be a good idea.)
> + error_init ("range of elements to initialize not at the end of designators");
This limitation should be documented.
> +/* Test for C99 designated initializer errors */
I suggest also testing for the constraint of 6.7.8p2 (not attempting to
initialize outside the object concerned), e.g. a designator giving too
large an array index.
I suggest following the idiom of the existing C standards tests of
checking that the errors are hard errors rather than warnings.
(Also, some basic tests c90-init-1.c that use of designated initializers
gives errors with -std=iso9899:1990 -pedantic-errors; and tests that use
of initializing ranges or the obsolete syntax give errors with
=std=iso9899:1999 -pedantic-errors.)
--
Joseph S. Myers
jsm28@cam.ac.uk