This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Allow compound literals in static storage duration objectinitializers


On Wed, 12 Dec 2001, Jakub Jelinek wrote:

> Note that I don't agree with !flag_isoc99, I'd think !pedantic
> would be more appropriate (or !pedantic and not -std=c99).

I don't think in C99 mode the extension makes sense, in the context of the
C99 meaning of compound literals as objects.  (In C89 mode -pedantic will 
of course already generate a warning for the compound literal, so no 
additional warning is needed there for the extension.)  Also note that 
-pedantic should never add errors, only warnings; -pedantic-errors should 
be needed for them to become errors.  I think just allowing this in C89 
mode is the best approach.

> a) handle it the same way as older gcc, which is kind of surprising
>    behaviour (this done in patch below)
> b) issue an error if compound literal's array type is not unknown
>    size and the size is different to the size of bracket enclosed
>    list
> c) handle it so that object gets size of the compound literal array type

If this extension were intentionally designed, clearly (c) would be 
appropriate; as it is, as an allowance for old code, (a), though 
surprising and of an odd design, may be best.

> 2001-12-12  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* c-typeck.c (digest_init): Allow initializing
> 	static storage duration objects with compound literals.
> 	* doc/extend.texi (Compound literals): Document the extension.
> 
> 	* testsuite/gcc.dg/gnu89-init-1.c: New test.

OK.

-- 
Joseph S. Myers
jsm28@cam.ac.uk


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]