Skip to content

Commit cbdc22a

Browse files
committed
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.
1 parent 220c593 commit cbdc22a

File tree

2 files changed

+17
-55
lines changed

2 files changed

+17
-55
lines changed

src/complain.c

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -109,41 +109,6 @@ flush (FILE *out)
109109
| --warnings's handling. |
110110
`------------------------*/
111111

112-
static const char * const warnings_args[] =
113-
{
114-
"none",
115-
"midrule-values",
116-
"yacc",
117-
"conflicts-sr",
118-
"conflicts-rr",
119-
"deprecated",
120-
"empty-rule",
121-
"precedence",
122-
"other",
123-
"all",
124-
"error",
125-
"everything",
126-
0
127-
};
128-
129-
static const warnings warnings_types[] =
130-
{
131-
Wnone,
132-
Wmidrule_values,
133-
Wyacc,
134-
Wconflicts_sr,
135-
Wconflicts_rr,
136-
Wdeprecated,
137-
Wempty_rule,
138-
Wprecedence,
139-
Wother,
140-
Wall,
141-
Werror,
142-
Weverything
143-
};
144-
145-
ARGMATCH_VERIFY (warnings_args, warnings_types);
146-
147112
ARGMATCH_DEFINE_GROUP(warning, warnings);
148113

149114
static const argmatch_warning_doc argmatch_warning_docs[] =
@@ -175,7 +140,6 @@ static const argmatch_warning_arg argmatch_warning_args[] =
175140
{ "precedence", Wprecedence },
176141
{ "other", Wother },
177142
{ "all", Wall },
178-
{ "error", Werror },
179143
{ "everything", Weverything },
180144
{ NULL, Wnone }
181145
};
@@ -197,8 +161,7 @@ warning_usage (FILE *out)
197161
void
198162
warning_argmatch (char const *arg, size_t no, size_t err)
199163
{
200-
int value = XARGMATCH ("--warning", arg + no + err,
201-
warnings_args, warnings_types);
164+
int value = *argmatch_warning_value ("--warning", arg + no + err);
202165

203166
/* -Wnone == -Wno-everything, and -Wno-none == -Weverything. */
204167
if (!value)
@@ -420,16 +383,17 @@ warning_is_enabled (warnings flags)
420383
static void
421384
warnings_print_categories (warnings warn_flags, FILE *out)
422385
{
423-
for (size_t i = 0; warnings_args[i]; ++i)
424-
if (warn_flags & warnings_types[i])
386+
for (int wbit = 0; wbit < warnings_size; ++wbit)
387+
if (warn_flags & (1 << wbit))
425388
{
426-
severity s = warning_severity (warnings_types[i]);
389+
warnings w = 1 << wbit;
390+
severity s = warning_severity (w);
427391
const char* style = severity_style (s);
428392
fputs (" [", out);
429393
begin_use_class (style, out);
430394
fprintf (out, "-W%s%s",
431395
s == severity_error ? "error=" : "",
432-
warnings_args[i]);
396+
argmatch_warning_argument (&w));
433397
end_use_class (style, out);
434398
fputc (']', out);
435399
/* Display only the first match, the second is "-Wall". */

src/complain.h

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ void flush (FILE *out);
4545
/** The bits assigned to each warning type. */
4646
typedef enum
4747
{
48-
warning_midrule_values, /**< Unset or unused midrule values. */
48+
warning_conflicts_rr,
49+
warning_conflicts_sr,
50+
warning_deprecated,
51+
warning_empty_rule,
52+
warning_midrule_values,
53+
warning_other,
54+
warning_precedence,
4955
warning_yacc, /**< POSIXME. */
50-
warning_conflicts_sr, /**< S/R conflicts. */
51-
warning_conflicts_rr, /**< R/R conflicts. */
52-
warning_empty_rule, /**< Implicitly empty rules. */
53-
warning_deprecated, /**< Obsolete constructs. */
54-
warning_precedence, /**< Useless precedence and associativity. */
55-
warning_other, /**< All other warnings. */
5656

5757
warnings_size /**< The number of warnings. Must be last. */
5858
} warning_bit;
@@ -102,16 +102,14 @@ typedef enum
102102
{
103103
Wnone = 0, /**< Issue no warnings. */
104104

105-
Wmidrule_values = 1 << warning_midrule_values,
106-
Wyacc = 1 << warning_yacc,
107-
Wconflicts_sr = 1 << warning_conflicts_sr,
108105
Wconflicts_rr = 1 << warning_conflicts_rr,
106+
Wconflicts_sr = 1 << warning_conflicts_sr,
109107
Wdeprecated = 1 << warning_deprecated,
110108
Wempty_rule = 1 << warning_empty_rule,
111-
Wprecedence = 1 << warning_precedence,
109+
Wmidrule_values = 1 << warning_midrule_values,
112110
Wother = 1 << warning_other,
113-
114-
Werror = 1 << 10, /** This bit is no longer used. */
111+
Wprecedence = 1 << warning_precedence,
112+
Wyacc = 1 << warning_yacc,
115113

116114
complaint = 1 << 11, /**< All complaints. */
117115
fatal = 1 << 12, /**< All fatal errors. */

0 commit comments

Comments
 (0)