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

[PATCH] Re: cpp(lib) vs. pedantic warnings vs. -Werror.


Neil Booth <neil@daikokuya.demon.co.uk> writes:
> > So, I guess the question is, what's the expected behaviour in CPP, and
> > is this a known issue, and what's the Right solution?
> 
> It's intentional, but I find it exceedingly confusing too.  pedwarn
> will upgrade to an error if -pedantic-errors, unlike a warning.
> Otherwise it's just like a warning.

right, so, the logic right now in gcc for warns / pedwarns seems to go
something like:

	if (it's a pedwarn and -pedantic-errors was given) {
		force an error
	}
	if (-Werror was given) {
		force an error
	}
	emit stuff, etc.

in cpp(lib), it's like:

	if (it's a pedwarn) {
		if (-pedantic-errors was given)
			force an error
		emit stuff, etc.
	} else {
		if (-Werror was given)
			force an error
		emit stuff, etc.
	}

It looks like -pedantic-errors also turns on -pedantic (in both cpp
and gcc), so there's no way currently in cpp to generate errors from
these warnings other than to turn on all pedantic warnings (yuck! 8-).

(hmm, doesn't look like tradcpp does a -Werror equiv, either...
unfortunately, it's not clear that that's a trivial enough patch that
i can reasonably submit it in my current state...)


I believe the trivial patch below will bring things in line with the
way gcc does this warning->error conversion, and is The Right Thing
(or as close as you can get without rototilling the code to a degree
that i currently can't do 8-).  I'm currently testing a build with it
on a mips-elf-like target, but it's simple enough that i thought i'd
post it before i'm done building...

If you want it, here it is.  If not, it'll live happily in my personal
tree.  8-)


2001-01-11  Chris Demetriou  <cgd@sibyte.com>

	* cpperror.c (_cpp_begin_message): In the PEDWARN case,
	great warnings as errors if warnings_are_errors is set.


Index: cpperror.c
===================================================================
RCS file: /cvsroot/systemsw/tools/src/gcc/gcc/cpperror.c,v
retrieving revision 1.4
diff -c -r1.4 cpperror.c
*** cpperror.c	2001/01/09 08:01:53	1.4
--- cpperror.c	2001/01/11 23:56:37
***************
*** 177,183 ****
        if (CPP_IN_SYSTEM_HEADER (pfile)
  	  && ! CPP_OPTION (pfile, warn_system_headers))
  	return 0;
!       if (! CPP_OPTION (pfile, pedantic_errors))
  	{
            if (CPP_OPTION (pfile, inhibit_warnings))
  	    return 0;
--- 177,184 ----
        if (CPP_IN_SYSTEM_HEADER (pfile)
  	  && ! CPP_OPTION (pfile, warn_system_headers))
  	return 0;
!       if (! CPP_OPTION (pfile, pedantic_errors)
! 	  && ! CPP_OPTION (pfile, warnings_are_errors))
  	{
            if (CPP_OPTION (pfile, inhibit_warnings))
  	    return 0;

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