- /* In a series of synonyms, present the most meaningful first, so
- that argmatch_valid be more readable. */
- "none - no warnings",
- "midrule-values - unset or unused midrule values",
- "yacc - incompatibilities with POSIX Yacc",
- "all - all of the above",
- "error - warnings are errors",
+ int value = 0;
+ if (!err || arg[no + err++] != '\0')
+ value = XARGMATCH ("--warning", arg + no + err,
+ warnings_args, warnings_types);
+
+ if (value)
+ {
+ if (no)
+ *flags &= ~value;
+ else
+ {
+ if (err)
+ warnings_flag |= value;
+ *flags |= value;
+ }
+ }
+ else
+ {
+ /* 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 |= Wall;
+ else
+ *flags &= ~Wall;
+ }
+}
+
+/** Decode a comma-separated list of arguments from -W.
+ *
+ * \param args comma separated list of effective subarguments to decode.
+ * If 0, then activate all the flags.
+ */
+static void
+warnings_argmatch (char *args)
+{
+ if (args)
+ for (args = strtok (args, ","); args; args = strtok (NULL, ","))
+ {
+ size_t no = STRPREFIX_LIT ("no-", args) ? 3 : 0;
+ size_t err = STRPREFIX_LIT ("error", args + no) ? 5 : 0;
+
+ warning_argmatch (err ? &errors_flag : &warnings_flag,
+ args, no, err);
+ }
+ else
+ warnings_flag |= Wall;
+}
+
+const char * const warnings_args[] =
+{
+ "none",
+ "midrule-values",
+ "yacc",
+ "conflicts-sr",
+ "conflicts-rr",
+ "deprecated",
+ "precedence",
+ "other",
+ "all",
+ "error",