🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Paul Eggert Wed, 12 Aug 1992 01:42
GCC 2.2.2 does not warn about partly bracketed initializers
#927
Author: Paul Eggert
Date: Wed, 12 Aug 1992 01:42
71 lines
2679 bytes
GCC 2.2.2 (Sparc, SunOS 4.1.2) does not warn about partly bracketed
initializers.  For example, in the following program, GCC does not
have an option to warn about the missing braces around `1,2':

	struct s { int f, g; };
	struct t { struct s h; int i; };
	struct t x = { 1, 2, 3 };

This is a nice warning to have because it catches some common typographical
errors.  This warning is also listed as a common warning in the ANSI C
standard (Appendix E).  Here's a patch that generates this warning when the -W
option is used.

Wed Aug 12 01:23:10 1992  Paul Eggert  (eggert@twinsun.com)

	* c-typeck.c (process_init_constructor): Warn about partly
	bracketed initializers.

===================================================================
RCS file: c-typeck.c,v
retrieving revision 2.2.2.4
diff -c -r2.2.2.4 c-typeck.c
*** c-typeck.c	1992/08/07 22:38:54	2.2.2.4
--- c-typeck.c	1992/08/12 01:23:10
***************
*** 4825,4831 ****
       no matter how the data was given to us.  */
  
    if (elts)
!     tail = *elts;
    else
      tail = CONSTRUCTOR_ELTS (init);
  
--- 4825,4835 ----
       no matter how the data was given to us.  */
  
    if (elts)
!     {
!       if (extra_warnings)
! 	warning ("aggregate has a partly bracketed initializer");
!       tail = *elts;
!     }
    else
      tail = CONSTRUCTOR_ELTS (init);
  
===================================================================
RCS file: invoke.texi,v
retrieving revision 2.2.2.2
diff -c -r2.2.2.2 invoke.texi
*** invoke.texi	1992/08/07 22:38:54	2.2.2.2
--- invoke.texi	1992/08/12 01:23:10
***************
*** 623,628 ****
--- 623,639 ----
  A storage-class specifier like @code{static} appears other than
  at the beginning of a declaration.  According to the C Standard,
  this usage is obsolescent.
+ 
+ @item
+ An aggregate has a partly bracketed initializer.
+ For example, the following code would evoke such a warning,
+ because braces are missing around the initializer for @samp{x.h}:
+ 
+ @example
+ struct s @{ int f, g; @};
+ struct t @{ struct s h; int i; @};
+ struct t x = @{ 1, 2, 3 @};
+ @end example
  @end itemize
  
  @item -Wimplicit
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads