X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/6652eeba585aff3e63b28d04435a4f9d8aeba43c..bb8e56ff67d289d15f1a4dc7f5e1502cd3bbfc24:/src/getargs.c diff --git a/src/getargs.c b/src/getargs.c index b0a6601a..db1c3869 100644 --- a/src/getargs.c +++ b/src/getargs.c @@ -83,63 +83,49 @@ flags_argmatch (const char *option, int all, int *flags, char *args) { if (args) - { - args = strtok (args, ","); - - /* Not sure whether we should keep this : -Werror=no-bar */ - int no = STRPREFIX_LIT ("no-", args) ? 3 : 0; - args += no; - int value = 0; - - while (args) { - int err = STRPREFIX_LIT ("error", args); - if (err) - args += (args[5] == '=') ? 6 : 5; - - if (!err || args[-1] == '=') - value = XARGMATCH (option, args, keys, values); - if (value == 0) - { - if (no) - { - if (err) - /* Using &= ~all activates complaint, silent and fatal */ - errors_flag = Wnone; - else - *flags |= all; - } - else - { - if (err) - errors_flag |= all; - else - *flags &= ~all; - } - } - else - { - if (no) - { - if (err) - errors_flag &= ~value; - else - *flags &= ~value; - } - else + args = strtok (args, ","); + while (args) { + int value = 0; + int *save_flags = flags; + int no = STRPREFIX_LIT ("no-", args) ? 3 : 0; + int err = STRPREFIX_LIT ("error", args + no) ? 5 : 0; + if (err) - { - errors_flag |= value; - warnings_flag |= value; - } + flags = &errors_flag; + if (!err || args[no + err++] != '\0') + value = XARGMATCH (option, args + no + err, keys, values); + + if (!value) + { + /* With a simpler 'if (no)' version, -Werror means -Werror=all + (or rather, -Werror=no-none, but that syntax is invalid). + The difference is: + - Werror activates all errors, but not the warnings + - Werror=all activates errors, and all warnings */ + if (no ? !err : err) + *flags |= all; + else + *flags &= ~all; + } else - *flags |= value; + { + if (no) + *flags &= ~value; + else + { + if (err) + warnings_flag |= value; + *flags |= value; + } + } + flags = save_flags; + args = strtok (NULL, ","); } - } - args = strtok (NULL, ","); } - } + else + *flags |= all; } /** Decode a set of sub arguments. @@ -354,17 +340,18 @@ Output:\n\ fputs (_("\ Warning categories include:\n\ - `midrule-values' unset or unused midrule values\n\ - `yacc' incompatibilities with POSIX Yacc\n\ - `conflicts-sr' S/R conflicts (enabled by default)\n\ - `conflicts-rr' R/R conflicts (enabled by default)\n\ - `other' all other warnings (enabled by default)\n\ - `all' all the warnings\n\ - `no-CATEGORY' turn off warnings in CATEGORY\n\ - `none' turn off all the warnings\n\ - `error' treat warnings as errors\n\ -\n\ + `midrule-values' unset or unused midrule values\n\ + `yacc' incompatibilities with POSIX Yacc\n\ + `conflicts-sr' S/R conflicts (enabled by default)\n\ + `conflicts-rr' R/R conflicts (enabled by default)\n\ + `deprecated' obsolete constructs\n\ + `other' all other warnings (enabled by default)\n\ + `all' all the warnings\n\ + `no-CATEGORY' turn off warnings in CATEGORY\n\ + `none' turn off all the warnings\n\ + `error[=CATEGORY]' treat warnings as errors\n\ "), stdout); + putc ('\n', stdout); fputs (_("\ THINGS is a list of comma separated words that can include:\n\ @@ -440,8 +427,8 @@ skeleton_arg (char const *arg, int prio, location loc) skeleton = arg; } else if (prio == skeleton_prio) - complain_at (loc, complaint, - _("multiple skeleton declarations are invalid")); + complain (&loc, complaint, + _("multiple skeleton declarations are invalid")); } void @@ -466,7 +453,7 @@ language_argmatch (char const *arg, int prio, location loc) else return; - complain_at (loc, complaint, msg, quotearg_colon (arg)); + complain (&loc, complaint, msg, quotearg_colon (arg)); } /*----------------------. @@ -699,6 +686,8 @@ getargs (int argc, char *argv[]) break; case 'y': + warnings_flag |= Wyacc; + errors_flag |= Wyacc; yacc_flag = true; break;