PATCH RFC: Warn about C++ keywords in C code with -Wcxx-compat

Kaveh R. GHAZI ghazi@caip.rutgers.edu
Thu Jul 10 19:42:00 GMT 2008


On Thu, 10 Jul 2008, Ian Lance Taylor wrote:

> I extended Tom Tromey's earlier patch to warn about C++ keywords in C
> code when using -Wcxx-compat.  This version attaches a special RID
> code to the identifiers about which it should warn.
>
> This patch only warns about a few C++ keywords.  My plan is to enable
> the warning one keyword at a time.  That will make it easier to change
> the gcc source code to avoid those keywords, rather than having to
> change everything at once.  Whether to warn about a keyword is
> controlled by the D_CXXWARN flag in the c_common_reswords array.  My
> goal is to enable the warning for all C++ keywords before the 4.4
> release

Oops!... I did it again. ;-)

I posted patches to clean up most of the /gcc directory based on an
earlier version of Tom's patch.  I'll be done with the remainder probably
today and will post when testing is finished.  Maybe someone can help with
the fortran and/or cp directories.  After I do the top level I'll move on
to testing conditional code for various targets and/or configuration
options.


> I have done a bootstrap and testsuite run, including ObjC++, on
> i686-unknown-linux-gnu.  (The ObjC++ testsuite has many failures, but
> it has the same number before and after this patch.)
> Ian

Yeah, I noticed that a few days ago.  Maybe we should add in objc++ to the
default bootstrap.
http://gcc.gnu.org/ml/gcc-patches/2008-03/msg01752.html

It only adds 42 seconds to the timing.
http://gcc.gnu.org/ml/gcc-patches/2008-03/msg01763.html

		--Kaveh
--
Kaveh R. Ghazi			ghazi@caip.rutgers.edu



More information about the Gcc-patches mailing list