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]
Other format: [Raw text]

Re: Option ordering


On 30 May 2007 16:12:12 -0700, Ian Lance Taylor <iant@google.com> wrote:
Joe Buck <Joe.Buck@synopsys.COM> writes:

> How about: have -Wall still set warn_strict_overflow
> to 1, but to have -Wall -Wstrict-overflow *or* -Wstrict-overflow -Wall
> *or* just -Wstrict-overflow set it to 2?  The only change would be
> to prevent -Wall from *decreasing* the value.

Sure, makes sense.

But, consider:
[snip]
If we want to fix this issue, it seems to me we should fix it
everywhere.

I was going to submit a formal proposal about options handling (with patches). Since this was raised before I had time to think it through properly, it may have some flaws.

Two kinds of options: group options (-Wall, -Wextra, -O1, -O2) and
simple options (-fpeephole, -Waddress, -Wstrict-overflow).

* Group options can only affect default values of simple options. So a
group option will not change the settings of a explicit simple option
no matter their order in the command-line. So, "-Wno-address -Wall" ==
"-Wall -Wno-address"

* Options are evaluated according to their order in the command-line.
So, "-Wno-address -Waddress" will turn on -Waddress, while "-Waddress
-Wno-address" will turn it off.

Both rules combined mean that you can do: "-Wall -Wno-all" disabling
"-Wall" warnings. However, if you do "-Waddress -Wall -Wno-all", you
still get -Waddress. You will need an explicit -Wno-address to disable
it.


I think this corresponds to the principle of least surprise. Bad idea?


Manuel.


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