Message ID | CAAgBjMkvPPYvL=kLGe8oJ6843jsEL2BZdYDEtWQwXZOGnKyfww@mail.gmail.com |
---|---|
State | New |
Headers | show |
On 1 May 2015 at 01:12, Paolo Carlini <paolo.carlini@oracle.com> wrote: > Hi again, > > On 04/30/2015 08:45 PM, Paolo Carlini wrote: >> >> .. also, your patch doesn't seem to fix the case of -w instead of That could be fixed as follows: if (!warn_narrowing || inhibit_warnings) ok = true; else // pedwarn >> -Wno-narrowing. I think we want to check the return value of the pedwarn >> instead. I'm testing something. > > I'm finishing testing the below: with hindsight, checking the return value > of the pedwarn makes a lot of sense to me! Indeed, checking return value of pedwarn is better compared to testing on warning flags. Thanks for pointing out -;) Regards, Prathamesh > > Paolo. > > ///////////////////////
Index: gcc/cp/typeck2.c =================================================================== --- gcc/cp/typeck2.c (revision 222573) +++ gcc/cp/typeck2.c (working copy) @@ -958,11 +958,17 @@ } else if (complain & tf_error) { - global_dc->pedantic_errors = 1; - pedwarn (EXPR_LOC_OR_LOC (init, input_location), OPT_Wnarrowing, - "narrowing conversion of %qE from %qT to %qT inside { }", - init, ftype, type); - global_dc->pedantic_errors = flag_pedantic_errors; + /* silence warning if -Wno-narrowing -is specified */ + if (!warn_narrowing) + ok = true; + else + { + global_dc->pedantic_errors = 1; + pedwarn (EXPR_LOC_OR_LOC (init, input_location), OPT_Wnarrowing, + "narrowing conversion of %qE from %qT to %qT inside { }", + init, ftype, type); + global_dc->pedantic_errors = flag_pedantic_errors; + } } }