This is the mail archive of the 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]

[RFC] Patch to flag obsolete initializer syntax usage


The purpose of this patch is to always flag the use of the obsolete
method of initializing structures and arrays. Here are examples of
this obsolete syntax taken from the GCC info pages (and slightly modified
for this mail) ...

struct point { int x, y; };
struct point p = { y: 10, x: 10 };

int a[6] = { [4] 29, [2] 15 };

Currently GCC can flag this format if '-pedantic' is used as a compile
flag, but that flag activates lots of other warnings as well. As the
usage demonstrated above is documented to have become obsolete with GCC
2.5, having the compile always warn about this usage seems reasonable.

The patch below simply removes the test for the pedantic flag, and by
default warns the user that the obsolete format is being used. This
patch is against GCC-3.3; I don't have 3.4 here. I've used a similar
patch with GCC-3.2 without problems.

If this patch is accepted, there are three or four files in the test
suite that need to be modified from the obsolete initializer syntax.
One or two tests for C99 syntax also have to be modified, and I have
simple patches for all these files.

Any interest in seeing this in GCC-3.3 or GCC-3.4?

Art Haas

RCS file: /cvsroot/gcc/gcc/gcc/,v
retrieving revision
diff -u -u -r1.152.14.1
---	28 Jan 2003 01:54:03 -0000
+++	14 Feb 2003 00:01:51 -0000
@@ -1538,12 +1538,10 @@
 		{ if (pedantic && ! flag_isoc99)
 		    pedwarn ("ISO C89 forbids specifying subobject to initialize"); }
 	| designator initval
-		{ if (pedantic)
-		    pedwarn ("obsolete use of designated initializer without `='"); }
+		{ warning ("obsolete use of designated initializer without `='"); }
 	| identifier ':'
 		{ set_init_label ($1);
-		  if (pedantic)
-		    pedwarn ("obsolete use of designated initializer with `:'"); }
+		  warning ("obsolete use of designated initializer with `:'"); }
 	| initval
They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety.
 -- Benjamin Franklin, Historical Review of Pennsylvania, 1759

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