On 19/05/21 11:51 -0600, Martin Sebor wrote:
On 5/19/21 10:39 AM, Jonathan Wakely via Gcc-patches wrote:
Jakub pointed out I'd forgotten the spaces before the opening parens
for function calls. The attached patch should fix all those, with no
other changes.
Tested x86_64-linux. OK for trunk?
Looks good to me, it just needs an update to the manual describing
the new options.
It's too bad that the conditionals checking for the dialect have
to be repeated throughout the front end. They're implied by
the new option enumerator passed to pedwarn(). If the diagnostic
subsystem had access to cxx_dialect the check could be done there
and all the other conditionals could be avoided. An alternative
to that would be to add a new wrapper to the C++ front end, like
cxxdialect_pedwarn, to do the checking before calling pedwarn
(or, more likely, emit_diagnostic_valist).
Actually, you've made me realise the conditionals aren't really
needed. The new warn_about_dialect_p predicate made sense for an
earlier version of my patch, but then I simplified it and now it's
mostly useless.
So in most places I can just leave if (cxx_dialect < cxx17) as the
controlling condition, and then just use OPT_Wc__17_extensions for the
pedwarn opt_code. And even the cxx_dialect check could be eliminated
if the value of warn_cxx11_extensions was set according to the
cxx_dialect (instead of Init(1) for all of them). i.e. Use Init(-1)
and then during option parsing set each according to the -std option:
if (warn_cxx11_extensions == -1)
warn_cxx11_extensions = cxx_dialect < cxx11;
if (warn_cxx14_extensions == -1)
warn_cxx14_extensions = cxx_dialect < cxx14;
if (warn_cxx17_extensions == -1)
warn_cxx17_extensions = cxx_dialect < cxx17;
etc.
IIUC that would mean that a pedwarn using OPT_Wc__14_extensions will
not warn when cxx_dialect >= cxx14, i.e. only warn about C++14
extensions if the active -std dialect is older than C++14. Which would
mean checking cxx_dialect before the pedwarn isn't needed.