diagnostics: use the modern argmatch interface

* src/complain.h (warnings): Remove Werror.
Adjust dependencies.
Sort.
Remove useless comments (see the doc in argmatch group).
* src/complain.c (warnings_args, warnings_types): Remove.
(warning_argmatch): Use argmatch_warning_value.
(warnings_print_categories): Use argmatch_warning_argument.
This commit is contained in:
Akim Demaille
2019-07-22 08:26:06 +02:00
parent 220c593a79
commit cbdc22af10
2 changed files with 17 additions and 55 deletions

View File

@@ -109,41 +109,6 @@ flush (FILE *out)
| --warnings's handling. |
`------------------------*/
static const char * const warnings_args[] =
{
"none",
"midrule-values",
"yacc",
"conflicts-sr",
"conflicts-rr",
"deprecated",
"empty-rule",
"precedence",
"other",
"all",
"error",
"everything",
0
};
static const warnings warnings_types[] =
{
Wnone,
Wmidrule_values,
Wyacc,
Wconflicts_sr,
Wconflicts_rr,
Wdeprecated,
Wempty_rule,
Wprecedence,
Wother,
Wall,
Werror,
Weverything
};
ARGMATCH_VERIFY (warnings_args, warnings_types);
ARGMATCH_DEFINE_GROUP(warning, warnings);
static const argmatch_warning_doc argmatch_warning_docs[] =
@@ -175,7 +140,6 @@ static const argmatch_warning_arg argmatch_warning_args[] =
{ "precedence", Wprecedence },
{ "other", Wother },
{ "all", Wall },
{ "error", Werror },
{ "everything", Weverything },
{ NULL, Wnone }
};
@@ -197,8 +161,7 @@ warning_usage (FILE *out)
void
warning_argmatch (char const *arg, size_t no, size_t err)
{
int value = XARGMATCH ("--warning", arg + no + err,
warnings_args, warnings_types);
int value = *argmatch_warning_value ("--warning", arg + no + err);
/* -Wnone == -Wno-everything, and -Wno-none == -Weverything. */
if (!value)
@@ -420,16 +383,17 @@ warning_is_enabled (warnings flags)
static void
warnings_print_categories (warnings warn_flags, FILE *out)
{
for (size_t i = 0; warnings_args[i]; ++i)
if (warn_flags & warnings_types[i])
for (int wbit = 0; wbit < warnings_size; ++wbit)
if (warn_flags & (1 << wbit))
{
severity s = warning_severity (warnings_types[i]);
warnings w = 1 << wbit;
severity s = warning_severity (w);
const char* style = severity_style (s);
fputs (" [", out);
begin_use_class (style, out);
fprintf (out, "-W%s%s",
s == severity_error ? "error=" : "",
warnings_args[i]);
argmatch_warning_argument (&w));
end_use_class (style, out);
fputc (']', out);
/* Display only the first match, the second is "-Wall". */

View File

@@ -45,14 +45,14 @@ void flush (FILE *out);
/** The bits assigned to each warning type. */
typedef enum
{
warning_midrule_values, /**< Unset or unused midrule values. */
warning_conflicts_rr,
warning_conflicts_sr,
warning_deprecated,
warning_empty_rule,
warning_midrule_values,
warning_other,
warning_precedence,
warning_yacc, /**< POSIXME. */
warning_conflicts_sr, /**< S/R conflicts. */
warning_conflicts_rr, /**< R/R conflicts. */
warning_empty_rule, /**< Implicitly empty rules. */
warning_deprecated, /**< Obsolete constructs. */
warning_precedence, /**< Useless precedence and associativity. */
warning_other, /**< All other warnings. */
warnings_size /**< The number of warnings. Must be last. */
} warning_bit;
@@ -102,16 +102,14 @@ typedef enum
{
Wnone = 0, /**< Issue no warnings. */
Wmidrule_values = 1 << warning_midrule_values,
Wyacc = 1 << warning_yacc,
Wconflicts_sr = 1 << warning_conflicts_sr,
Wconflicts_rr = 1 << warning_conflicts_rr,
Wconflicts_sr = 1 << warning_conflicts_sr,
Wdeprecated = 1 << warning_deprecated,
Wempty_rule = 1 << warning_empty_rule,
Wprecedence = 1 << warning_precedence,
Wmidrule_values = 1 << warning_midrule_values,
Wother = 1 << warning_other,
Werror = 1 << 10, /** This bit is no longer used. */
Wprecedence = 1 << warning_precedence,
Wyacc = 1 << warning_yacc,
complaint = 1 << 11, /**< All complaints. */
fatal = 1 << 12, /**< All fatal errors. */