From: Art Haas <ahaas@airmail.net>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] GCC patch for detecting pre-C99 initializers
Date: Thu, 5 Dec 2002 16:44:50 -0600 [thread overview]
Message-ID: <20021205224450.GA10638@debian> (raw)
Hi.
The latest kernels have stamped out many of the pre-C99 initializers,
and 2.5.51 will remove even more. There are still a few hanging around
here and there, and some will be fixed when Linus merges updates for
various bits of code (i.e. framebuffer, things in drivers/mtd, etc).
Here's a handy little patch I've just built GCC with that will warn if
the obsolete style initializers are used. GCC-3.2 can do this now if the
'-pedantic' flag is used, but building a kernel with that flag generates
a huge amount of noise, and adding '-std=gnu99' reduces some of it, but
then the kernel fails to build do to compiler problems. This patch
changes GCC so it always warns if it encounters an old style
initializer. No flags are needed to activate this warning (and none turn
it off), so it will always catch these obsolete constructs. This patch
flagged a few initializers that my script for doing the changes had missed,
so it's proven useful to me already. Hopefully others will agree.
If you rebuild the compiler with this patch and run the test suite, be
aware that a number of failures will occur due to the warnings printed
out because of the old initializers. A few files in the test suite need
patching so they either use the new initializers or expect the warnings.
Also, building a 2.4 kernel with the modified compiler will produce lots
of warnings, so the compiler would best be used for just dealing with
2.5 kernels.
The patch is against the current gcc-3-2 branch. I don't have a patch
for what will become 3-3, but I'll bet this could be used there. As the
old style constructs have been obsolete since gcc-2.5, it may be
worthwhile to try and get this into the GCC-3.3 compiler. I don't know
what the feelings are regarding that are, so I'll see what sort of
feedback I get from posting this ( no flames please! :-) ) before it
would be sent off to GCC land.
Art Haas
Index: gcc/c-parse.in
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/c-parse.in,v
retrieving revision 1.127.2.2.4.2
diff -u -r1.127.2.2.4.2 c-parse.in
--- gcc/c-parse.in 21 Oct 2002 18:37:41 -0000 1.127.2.2.4.2
+++ gcc/c-parse.in 5 Dec 2002 22:29:12 -0000
@@ -1520,12 +1520,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
{}
| 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
reply other threads:[~2002-12-05 22:37 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20021205224450.GA10638@debian \
--to=ahaas@airmail.net \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox