On Wed, Oct 12, 2016 at 12:34:45AM +0200, Bernd Schmidt wrote: > On 10/11/2016 11:52 PM, Jakub Jelinek wrote: > >The following patch introduces difference warning levels for > >-Wimplicit-fallthrough warning, so projects can choose if they want to > >honor only attributes (-Wimplicit-fallthrough=5), or what kind of comments. > >=4 is very picky and accepts only very small amount of comments, =3 is what > >we had before this patch, =2 looks case insensitively for falls?[ > >\t-]*thr(u|ough) > >anywhere in the comment, =1 accepts any comment, =0 is the same as > >-Wno-implicit-fallthrough - disables the warning. > > > >Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? > > I think this is ok, and thank you very much for doing this. > > >The patch keeps as the default the current forms, I'm not against changing > >it to =2 if there is consensus on it, but would strongly prefer doing that > >incrementally, as e.g. we'll need to adjust the testsuite for that, and > >perhaps also use =3 as the warning for gcc bootstraps when we are already =3 > >mode clear. > > It's a discussion we should have, but I agree it should be done > incrementally. I would argue for =1 as the default. > > > * c.opt (Wextra): Add as C/C++/ObjC/ObjC++ option. > > (Wimplicit-fallthrough=): Enable for these languages by -Wextra. > > This bit looks like it does a bit more magic than is immediately obvious. > Could you elaborate how this works?
It is all magic to get it working correctly, took me a while to figure it out. The thing is that EnabledBy doesn't support the positive and negative arguments (and after all, -Wimplicit-fallthrough doesn't make much sense to be enabled for non-C family of languages from -Wextra), so it needs LangEnabledBy. But, LangEnabledBy will not work if the option doesn't have a corresponding language mask, so I had to add that mask to it, otherwise C_handle_option_auto, CXX_handle_option_auto etc. wouldn't be called for that option. E.g. fortran/lang.opt already had: Wcompare-reals Fortran Warning Var(warn_compare_reals) LangEnabledBy(Fortran,Wextra) Warn about equality comparisons involving REAL or COMPLEX expressions. and to be able to do that also had: Wextra Fortran Warning ; Documented in common -Wall which has far more LangEnabledBy uses is even not defined in common.opt, only in the FE *.opt files. Wunused is another option that is similarly copied/extended in c.opt, so that it can be used in LangEnabledBy and can also have its own LangEnabledBy. Jakub