This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Error on Enum option without RejectNegative
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: Eric Botcazou <ebotcazou at adacore dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 4 Jan 2017 22:13:05 +0100
- Subject: [PATCH] Error on Enum option without RejectNegative
- Authentication-results: sourceware.org; auth=none
- References: <20170102192726.GH21933@tucnak> <CAFiYyc3jFQXnsGSV5iuJuEc6cm0Sa=3=amDcirP46brRpRvXjw@mail.gmail.com> <20170104114031.GI21933@tucnak> <CAFiYyc2WJFPpYbGOebwNmfyyrOJXXoTJpecN8mcEEWKmDSxxBg@mail.gmail.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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