+ else
+ {
+ size_t b;
+ for (b = 0; b < warnings_size; ++b)
+ if (value & 1 << b)
+ /* -Wfoo and -Werror=foo. */
+ warnings_flag[b] = err ? severity_error : severity_warning;
+ }
+}
+
+/** 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.
+ */
+
+void
+warnings_argmatch (char *args)
+{
+ if (args)
+ for (args = strtok (args, ","); args; args = strtok (NULL, ","))
+ if (STREQ (args, "error"))
+ warnings_are_errors = true;
+ else if (STREQ (args, "no-error"))
+ {
+ warnings_are_errors = false;
+ warning_argmatch ("no-error=all", 3, 6);
+ }
+ else
+ {
+ size_t no = STRPREFIX_LIT ("no-", args) ? 3 : 0;
+ size_t err = STRPREFIX_LIT ("error=", args + no) ? 6 : 0;
+
+ warning_argmatch (args, no, err);
+ }
+ else
+ warning_argmatch ("all", 0, 0);
+}
+
+
+/*-----------.
+| complain. |
+`-----------*/
+
+void
+complain_init (void)
+{
+ warnings warnings_default =
+ Wconflicts_sr | Wconflicts_rr | Wdeprecated | Wother;
+
+ size_t b;
+ for (b = 0; b < warnings_size; ++b)
+ warnings_flag[b] = (1 << b & warnings_default
+ ? severity_warning
+ : severity_unset);
+}
+
+static severity
+warning_severity (warnings flags)
+{
+ if (flags & fatal)
+ return severity_fatal;
+ else if (flags & complaint)
+ return severity_error;
+ else
+ {
+ severity res = severity_disabled;
+ size_t b;
+ for (b = 0; b < warnings_size; ++b)
+ if (flags & 1 << b)
+ res = res < warnings_flag[b] ? warnings_flag[b] : res;
+ if (res == severity_warning && warnings_are_errors)
+ res = severity_error;
+ return res;
+ }
+}
+
+
+/** Display a "[-Wyacc]" like message on \a f. */
+
+static void
+warnings_print_categories (warnings warn_flags, FILE *f)
+{
+ /* Display only the first match, the second is "-Wall". */
+ size_t i;
+ for (i = 0; warnings_args[i]; ++i)
+ if (warn_flags & warnings_types[i])
+ {
+ severity s = warning_severity (warnings_types[i]);
+ fprintf (f, " [-W%s%s]",
+ s == severity_error ? "error=" : "",
+ warnings_args[i]);
+ return;
+ }