diagnostics: modernize the display of submessages

Since Bison 2.7, output was indented four spaces for explanatory
statements.  For example:

    input.y:2.7-13: error: %type redeclaration for exp
    input.y:1.7-11:     previous declaration

Since the introduction of caret-diagnostics, it became less clear.
Remove the indentation and display submessages as in GCC:

    input.y:2.7-13: error: %type redeclaration for exp
        2 | %type <float> exp
          |       ^~~~~~~
    input.y:1.7-11: note: previous declaration
        1 | %type <int> exp
          |       ^~~~~

* src/complain.h (SUB_INDENT): Remove.
(warnings): Add "note" to the enum.
* src/complain.h, src/complain.c (complain_indent): Replace by...
(subcomplain): this.
Adjust all dependencies.
* tests/actions.at, tests/diagnostics.at, tests/glr-regression.at,
* tests/input.at, tests/named-refs.at, tests/regression.at:
Adjust expectations.
This commit is contained in:
Victor Morales Cayuela
2020-02-14 18:41:55 +01:00
committed by Akim Demaille
parent a09d0ae4d1
commit e09a72eeb0
16 changed files with 284 additions and 364 deletions

View File

@@ -21,9 +21,6 @@
# include "location.h"
/* Sub-messages indent. */
# define SUB_INDENT (4)
/*---------------.
| Error stream. |
`---------------*/
@@ -119,6 +116,7 @@ typedef enum
fatal = 1 << 12, /**< All fatal errors. */
silent = 1 << 13, /**< Do not display the warning type. */
no_caret = 1 << 14, /**< Do not display caret location. */
note = 1 << 15, /**< Display as a note. */
/**< All above warnings. */
Weverything = ~complaint & ~fatal & ~silent,
@@ -137,13 +135,13 @@ void complain (location const *loc, warnings flags, char const *message, ...)
__attribute__ ((__format__ (__printf__, 3, 4)));
/** Likewise, but with an \a argc/argv interface. */
void complain_args (location const *loc, warnings w, int *indent,
void complain_args (location const *loc, warnings w,
int argc, char *arg[]);
/** Make a complaint with location and some indentation. */
void complain_indent (location const *loc, warnings flags, int *indent,
char const *message, ...)
__attribute__ ((__format__ (__printf__, 4, 5)));
/** Make a subcomplain with location and note. */
void subcomplain (location const *loc, warnings flags,
char const *message, ...)
__attribute__ ((__format__ (__printf__, 3, 4)));
/** GNU Bison extension not valid with POSIX Yacc. */