mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-19 01:03:04 +00:00
diagnostics: expose a means to know whether a warning is enabled
* src/complain.h, src/complain.c (warning_is_enabled): New.
This commit is contained in:
@@ -338,12 +338,17 @@ warning_is_unset (warnings flags)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
warning_is_enabled (warnings flags)
|
||||||
|
{
|
||||||
|
return severity_warning <= warning_severity (flags);
|
||||||
|
}
|
||||||
|
|
||||||
/** Display a "[-Wyacc]" like message on \a out. */
|
/** Display a "[-Wyacc]" like message on \a out. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
warnings_print_categories (warnings warn_flags, FILE *out)
|
warnings_print_categories (warnings warn_flags, FILE *out)
|
||||||
{
|
{
|
||||||
/* Display only the first match, the second is "-Wall". */
|
|
||||||
for (size_t i = 0; warnings_args[i]; ++i)
|
for (size_t i = 0; warnings_args[i]; ++i)
|
||||||
if (warn_flags & warnings_types[i])
|
if (warn_flags & warnings_types[i])
|
||||||
{
|
{
|
||||||
@@ -356,6 +361,7 @@ warnings_print_categories (warnings warn_flags, FILE *out)
|
|||||||
warnings_args[i]);
|
warnings_args[i]);
|
||||||
end_use_class (style, out);
|
end_use_class (style, out);
|
||||||
fputc (']', out);
|
fputc (']', out);
|
||||||
|
/* Display only the first match, the second is "-Wall". */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -426,8 +432,7 @@ error_message (const location *loc, warnings flags, severity sever,
|
|||||||
fflush (stderr);
|
fflush (stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Raise a complaint. That can be a fatal error, an error or just a
|
/** Raise a complaint (fatal error, error or just warning). */
|
||||||
warning. */
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
complains (const location *loc, warnings flags, const char *message,
|
complains (const location *loc, warnings flags, const char *message,
|
||||||
|
|||||||
@@ -125,6 +125,9 @@ typedef enum
|
|||||||
(Never enabled, never disabled). */
|
(Never enabled, never disabled). */
|
||||||
bool warning_is_unset (warnings flags);
|
bool warning_is_unset (warnings flags);
|
||||||
|
|
||||||
|
/** Whether warnings of \a flags should be reported. */
|
||||||
|
bool warning_is_enabled (warnings 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)));
|
||||||
|
|||||||
Reference in New Issue
Block a user