On 14/10/17 16:32, Oren Ben-Kiki wrote:
Thanks for the pointers. I'm not currently using auto tools, but I might
end up having to use them, or cmake. Having these macros would help. I
still wish we had `-Wno-unknown-warnings` though - it would make life much
simpler.
Despite the feedback that you have received so far, I think that if you
actually submitted a proper patch, it will be accepted.
One possible implementation could behave as follows:
1. By default, keep current behavior.
2. With -Wno-error=unknown-option, warn instead of error.
3. With -Wno-unknown-option, do not diagnose unknown options (use at your
peril!).
--- opts-common.c (revision 253833)
+++ opts-common.c (working copy)
@@ -1230,7 +1230,8 @@
if (decoded->opt_index == OPT_SPECIAL_unknown)
{
if (handlers->unknown_option_callback (decoded))
- error_at (loc, "unrecognized command line option %qs", decoded->arg);
+ warning_at (loc, OPT_Wunknown_option,
+ "unrecognized command line option %qs", decoded->arg);
return;
}
--- opts-global.c (revision 251201)
+++ opts-global.c (working copy)
@@ -134,7 +134,7 @@
const char *opt;
opt = ignored_options.pop ();
- warning_at (UNKNOWN_LOCATION, 0,
+ warning_at (UNKNOWN_LOCATION, OPT_Wunknown_option,
"unrecognized command line option %qs", opt);
}
}
--- toplev.c (revision 253834)
+++ toplev.c (working copy)
@@ -1650,14 +1650,23 @@
|| !targetm.have_prologue () || !targetm.have_epilogue ())
flag_ipa_ra = 0;
- /* Enable -Werror=coverage-mismatch when -Werror and -Wno-error
- have not been set. */
- if (!global_options_set.x_warnings_are_errors
- && warn_coverage_mismatch
- && (global_dc->classify_diagnostic[OPT_Wcoverage_mismatch] ==
- DK_UNSPECIFIED))
- diagnostic_classify_diagnostic (global_dc, OPT_Wcoverage_mismatch,
- DK_ERROR, UNKNOWN_LOCATION);
+ if (!global_options_set.x_warnings_are_errors)
+ {
+ /* Enable -Werror=coverage-mismatch when -Werror and -Wno-error
+ have not been set. */
+ if (warn_coverage_mismatch
+ && (global_dc->classify_diagnostic[OPT_Wcoverage_mismatch] ==
+ DK_UNSPECIFIED))
+ diagnostic_classify_diagnostic (global_dc, OPT_Wcoverage_mismatch,
+ DK_ERROR, UNKNOWN_LOCATION);
+ /* Enable -Werror=unknown-option when -Werror and -Wno-error
+ have not been set. */
+ if (warn_unknown_option
+ && (global_dc->classify_diagnostic[OPT_Wunknown_option] ==
+ DK_UNSPECIFIED))
+ diagnostic_classify_diagnostic (global_dc, OPT_Wunknown_option,
+ DK_ERROR, UNKNOWN_LOCATION);
+ }
/* Save the current optimization options. */
optimization_default_node = build_optimization_node (&global_options);
--- common.opt (revision 251201)
+++ common.opt (working copy)
@@ -634,6 +634,10 @@
Common Var(warn_null_dereference) Warning
Warn if dereferencing a NULL pointer may lead to erroneous or undefined
behavior.
+Wunknown-option
+Common Var(warn_unknown_option) Init(1) Warning
+Warn for unknown command-line options. This is an error by default.
+
Wunsafe-loop-optimizations
Common Var(warn_unsafe_loop_optimizations) Warning
Warn if the loop cannot be optimized due to nontrivial assumptions.
The above is not a proper patch, just a draft of an idea. Now you only need to
follow the instructions here:
https://gcc.gnu.org/wiki/GettingStarted#Basics:_Contributing_to_GCC_in_10_easy_steps
Cheers,
Manuel.