mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-20 01:33:03 +00:00
diagnostics: factor the list of warning names
* src/getargs.h, src/getargs.c (warnings_args, warnings_types): Make them public. * src/complain.h, src/complain.c (warnings_print_categories): Its only use outside complain.c was removed in a recent commit, so make it static. Simplify its implementation. Use warnings_args and warnings_types. * src/muscle-tab.c (muscle_percent_define_check_values): Make it silent.
This commit is contained in:
@@ -38,35 +38,20 @@ warnings errors_flag;
|
|||||||
err_status complaint_status = status_none;
|
err_status complaint_status = status_none;
|
||||||
static unsigned *indent_ptr = 0;
|
static unsigned *indent_ptr = 0;
|
||||||
|
|
||||||
void
|
/** Display a "[-Wyacc]" like message on \a f. */
|
||||||
warnings_print_categories (warnings warn_flags)
|
|
||||||
{
|
|
||||||
if (! (warn_flags & silent))
|
|
||||||
{
|
|
||||||
char const *warn_names[] =
|
|
||||||
{
|
|
||||||
"midrule-values",
|
|
||||||
"yacc",
|
|
||||||
"conflicts-sr",
|
|
||||||
"conflicts-rr",
|
|
||||||
"deprecated",
|
|
||||||
"precedence",
|
|
||||||
"other"
|
|
||||||
};
|
|
||||||
|
|
||||||
bool any = false;
|
static void
|
||||||
int i;
|
warnings_print_categories (warnings warn_flags, FILE *f)
|
||||||
for (i = 0; i < ARRAY_CARDINALITY (warn_names); ++i)
|
{
|
||||||
if (warn_flags & 1 << i)
|
/* Display only the first match, the second is "-Wall". */
|
||||||
{
|
int i;
|
||||||
bool err = warn_flags & errors_flag;
|
for (i = 0; warnings_args[i]; ++i)
|
||||||
fprintf (stderr, "%s-W", any ? ", " : " [");
|
if (warn_flags & warnings_types[i])
|
||||||
fprintf (stderr, "%s%s", err ? "error=" : "" , warn_names[i]);
|
{
|
||||||
any = true;
|
bool err = warn_flags & errors_flag;
|
||||||
}
|
fprintf (f, " [-W%s%s]", err ? "error=" : "" , warnings_args[i]);
|
||||||
if (any)
|
break;
|
||||||
fprintf (stderr, "]");
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Report an error message.
|
/** Report an error message.
|
||||||
@@ -109,7 +94,8 @@ error_message (const location *loc, warnings flags, const char *prefix,
|
|||||||
fprintf (stderr, "%s: ", prefix);
|
fprintf (stderr, "%s: ", prefix);
|
||||||
|
|
||||||
vfprintf (stderr, message, args);
|
vfprintf (stderr, message, args);
|
||||||
warnings_print_categories (flags);
|
if (! (flags & silent))
|
||||||
|
warnings_print_categories (flags, stderr);
|
||||||
{
|
{
|
||||||
size_t l = strlen (message);
|
size_t l = strlen (message);
|
||||||
if (l < 2 || message[l - 2] != ':' || message[l - 1] != ' ')
|
if (l < 2 || message[l - 2] != ':' || message[l - 1] != ' ')
|
||||||
|
|||||||
@@ -57,9 +57,6 @@ extern warnings warnings_flag;
|
|||||||
/** What warnings are made errors. */
|
/** What warnings are made errors. */
|
||||||
extern warnings errors_flag;
|
extern warnings errors_flag;
|
||||||
|
|
||||||
/** Display a "[-Wyacc]" like message on stderr. */
|
|
||||||
void warnings_print_categories (warnings warn_flags);
|
|
||||||
|
|
||||||
/** Make a complaint, with maybe a location. */
|
/** Make a complaint, with maybe a location. */
|
||||||
void complain (location const *loc, warnings flags, char const *message, ...)
|
void complain (location const *loc, warnings flags, char const *message, ...)
|
||||||
__attribute__ ((__format__ (__printf__, 3, 4)));
|
__attribute__ ((__format__ (__printf__, 3, 4)));
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ ARGMATCH_VERIFY (trace_args, trace_types);
|
|||||||
| --warnings's handling. |
|
| --warnings's handling. |
|
||||||
`------------------------*/
|
`------------------------*/
|
||||||
|
|
||||||
static const char * const warnings_args[] =
|
const char * const warnings_args[] =
|
||||||
{
|
{
|
||||||
"none",
|
"none",
|
||||||
"midrule-values",
|
"midrule-values",
|
||||||
@@ -255,7 +255,7 @@ static const char * const warnings_args[] =
|
|||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int warnings_types[] =
|
const int warnings_types[] =
|
||||||
{
|
{
|
||||||
Wnone,
|
Wnone,
|
||||||
Wmidrule_values,
|
Wmidrule_values,
|
||||||
|
|||||||
@@ -121,6 +121,14 @@ enum feature
|
|||||||
/** What additional features to use. */
|
/** What additional features to use. */
|
||||||
extern int feature_flag;
|
extern int feature_flag;
|
||||||
|
|
||||||
|
/*------------.
|
||||||
|
| --warning. |
|
||||||
|
`------------*/
|
||||||
|
/* Null-terminated list. */
|
||||||
|
extern const char * const warnings_args[];
|
||||||
|
extern const int warnings_types[];
|
||||||
|
|
||||||
|
|
||||||
/** Process the command line arguments.
|
/** Process the command line arguments.
|
||||||
*
|
*
|
||||||
* \param argc size of \a argv
|
* \param argc size of \a argv
|
||||||
|
|||||||
@@ -664,7 +664,7 @@ muscle_percent_define_check_values (char const * const *values)
|
|||||||
quote (*variablep), quote_n (1, value));
|
quote (*variablep), quote_n (1, value));
|
||||||
i += SUB_INDENT;
|
i += SUB_INDENT;
|
||||||
for (values = variablep + 1; *values; ++values)
|
for (values = variablep + 1; *values; ++values)
|
||||||
complain_indent (&loc, complaint | no_caret, &i,
|
complain_indent (&loc, complaint | no_caret | silent, &i,
|
||||||
_("accepted value: %s"), quote (*values));
|
_("accepted value: %s"), quote (*values));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user