[PATCH] Error on Enum option without RejectNegative

Jakub Jelinek jakub@redhat.com
Wed Jan 4 21:13:00 GMT 2017


On Wed, Jan 04, 2017 at 01:31:28PM +0100, Richard Biener wrote:
> > Rather than implicit RejectNegative it might be better to just diagnose
> > such options as invalid.  If you agree, I can implement that as follow-up.
> > Also note that RejectNegative is only needed on the Enum switches that have
> > the default negatives (that is [Wfm] prefixed I think).
> 
> That would be nice.

This works (and r244071 fails to build with it, r244072 succeeds).
The error is emitted above the option, so it is not hard to find out what
option it is (and it is similar to other similar errors diagnosed by
optc-gen.awk).
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2017-01-04  Jakub Jelinek  <jakub@redhat.com>

	* optc-gen.awk: Emit #error for -W*/-f*/-m* Enum without
	RejectNegative.

--- gcc/optc-gen.awk.jj	2017-01-01 12:45:39.000000000 +0100
+++ gcc/optc-gen.awk	2017-01-04 18:24:58.926573992 +0100
@@ -326,6 +326,11 @@ for (i = 0; i < n_opts; i++) {
 			alias_data = "NULL, NULL, OPT_SPECIAL_ignore"
 		else
 			alias_data = "NULL, NULL, N_OPTS"
+		if (flag_set_p("Enum.*", flags[i])) {
+			if (!flag_set_p("RejectNegative", flags[i]) \
+			    && opts[i] ~ "^[Wfm]")
+				print "#error Enum allowing negative form"
+		}
 	} else {
 		alias_opt = nth_arg(0, alias_arg)
 		alias_posarg = nth_arg(1, alias_arg)


	Jakub



More information about the Gcc-patches mailing list