diagnostics: style changes

* src/complain.h, src/complain.c: Comment changes.
* src/scan-skel.l: Reduce scopes.
* data/skeletons/bison.m4: Factor diagnostic functions.
This commit is contained in:
Akim Demaille
2019-12-02 18:56:46 +01:00
parent 8b53f4e022
commit 9e9e49224f
4 changed files with 14 additions and 10 deletions

View File

@@ -192,7 +192,7 @@ m4_define([b4_error],
# @warn(1@) # @warn(1@)
# @warn(1@,2@) # @warn(1@,2@)
m4_define([b4_warn], m4_define([b4_warn],
[b4_error([[warn]], [], [], $@)]) [b4_warn_at([], [], $@)])
# b4_warn_at(START, END, FORMAT, [ARG1], [ARG2], ...) # b4_warn_at(START, END, FORMAT, [ARG1], [ARG2], ...)
# --------------------------------------------------- # ---------------------------------------------------
@@ -210,7 +210,7 @@ m4_define([b4_warn_at],
# #
# See b4_warn example. # See b4_warn example.
m4_define([b4_complain], m4_define([b4_complain],
[b4_error([[complain]], [], [], $@)]) [b4_complain_at([], [], $@)])
# b4_complain_at(START, END, FORMAT, [ARG1], [ARG2], ...) # b4_complain_at(START, END, FORMAT, [ARG1], [ARG2], ...)
# ------------------------------------------------------- # -------------------------------------------------------
@@ -226,8 +226,7 @@ m4_define([b4_complain_at],
# #
# See b4_warn example. # See b4_warn example.
m4_define([b4_fatal], m4_define([b4_fatal],
[b4_error([[fatal]], [], [], $@)dnl [b4_fatal_at([], [], $@)])
m4_exit(1)])
# b4_fatal_at(START, END, FORMAT, [ARG1], [ARG2], ...) # b4_fatal_at(START, END, FORMAT, [ARG1], [ARG2], ...)
# ---------------------------------------------------- # ----------------------------------------------------

View File

@@ -225,6 +225,7 @@ warnings_argmatch (char *args)
} }
} }
/* Color style for this type of message. */
static const char* static const char*
severity_style (severity s) severity_style (severity s)
{ {
@@ -242,6 +243,7 @@ severity_style (severity s)
abort (); abort ();
} }
/* Prefix for this type of message. */
static const char* static const char*
severity_prefix (severity s) severity_prefix (severity s)
{ {

View File

@@ -61,6 +61,7 @@ typedef enum
/** Whether -Werror was set. */ /** Whether -Werror was set. */
extern bool warnings_are_errors; extern bool warnings_are_errors;
/** Document --warning arguments. */
void warning_usage (FILE *out); void warning_usage (FILE *out);
/** Decode a single argument from -W. /** Decode a single argument from -W.
@@ -99,6 +100,7 @@ void complain_free (void);
/** Initialize support for colored messages. */ /** Initialize support for colored messages. */
void complain_init_color (void); void complain_init_color (void);
/** Flags passed to diagnostics functions. */
typedef enum typedef enum
{ {
Wnone = 0, /**< Issue no warnings. */ Wnone = 0, /**< Issue no warnings. */

View File

@@ -209,22 +209,23 @@ at_basename (int argc, char *argv[], char **out_namep, int *out_linenop)
static void static void
at_complain (int argc, char *argv[], char **out_namep, int *out_linenop) at_complain (int argc, char *argv[], char **out_namep, int *out_linenop)
{ {
static int indent; if (argc < 4)
warnings w = flag (argv[1]); fail_for_at_directive_too_few_args (argv[0]);
location loc;
location *locp = NULL;
(void) out_namep; (void) out_namep;
(void) out_linenop; (void) out_linenop;
if (argc < 4) warnings w = flag (argv[1]);
fail_for_at_directive_too_few_args (argv[0]);
location loc;
location *locp = NULL;
if (argv[2] && argv[2][0]) if (argv[2] && argv[2][0])
{ {
boundary_set_from_string (&loc.start, argv[2]); boundary_set_from_string (&loc.start, argv[2]);
boundary_set_from_string (&loc.end, argv[3]); boundary_set_from_string (&loc.end, argv[3]);
locp = &loc; locp = &loc;
} }
static int indent;
if (w & silent) if (w & silent)
indent += SUB_INDENT; indent += SUB_INDENT;
else else