http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50810
--- Comment #5 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2011-10-22 01:24:25 UTC --- (In reply to comment #4) > (In reply to comment #3) > > (detail: not sure about the 'if (!warn_narrowing) return;' at the beginning > > of > > check_narrowing: probably we don't want -Wno-narrowing to suppress the > > warnings > > enabled of -Wc++0x-compat) > > I think what you want is that -Wc++0x-compat enables -Wnarrowing independently > of -std=, but still -Wc++0x-compat -Wno-narrowing should disable it. See the > handling of Wlonglong in c-opts.c. So: > > if (!ok) > { > if (cxx_dialect != cxx98) > pedwarn (input_location, OPT_Wnarrowing, "narrowing conversion of %qE > " > "from %qT to %qT inside { }", init, ftype, type); > else > warning_at (input_location, OPT_Wnarrowing, "narrowing conversion of > %qE " > "from %qT to %qT inside { }", init, ftype, type); > } > You can even make this more compact by using emit_diagnostic: emit_diagnostic ((cxx_dialect != cxx98) ? DK_PEDWARN : DK_WARNING, input_location, OPT_Wnarrowing, "narrowing conversion of %qE from %qT to %qT inside { }", init, ftype, type); The C FE has wrappers around something similar called pedwarn_c99, that is, a pedwarn in C99, otherwise just a warning. You could add something similar to C++.