mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-17 00:03:03 +00:00
diagnostics: factor the deprecated directive message
* src/complain.h, src/complain.c (deprecated_directive): New. * src/muscle-tab.c: Use it.
This commit is contained in:
@@ -28,6 +28,7 @@
|
|||||||
#include "complain.h"
|
#include "complain.h"
|
||||||
#include "files.h"
|
#include "files.h"
|
||||||
#include "getargs.h"
|
#include "getargs.h"
|
||||||
|
#include "quote.h"
|
||||||
|
|
||||||
warnings warnings_flag =
|
warnings warnings_flag =
|
||||||
Wconflicts_sr | Wconflicts_rr | Wdeprecated | Wother;
|
Wconflicts_sr | Wconflicts_rr | Wdeprecated | Wother;
|
||||||
@@ -188,4 +189,18 @@ complain_args (location const *loc, warnings w, unsigned *indent,
|
|||||||
complain (loc, fatal, "too many arguments for complains");
|
complain (loc, fatal, "too many arguments for complains");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
deprecated_directive (location const *loc, char const *old, char const *upd)
|
||||||
|
{
|
||||||
|
if (feature_flag & feature_caret)
|
||||||
|
complain (loc, Wdeprecated,
|
||||||
|
_("deprecated directive, use %s"),
|
||||||
|
quote_n (1, upd));
|
||||||
|
else
|
||||||
|
complain (loc, Wdeprecated,
|
||||||
|
_("deprecated directive: %s, use %s"),
|
||||||
|
quote (old), quote_n (1, upd));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,6 +72,10 @@ void complain_indent (location const *loc, warnings flags, unsigned *indent,
|
|||||||
__attribute__ ((__format__ (__printf__, 4, 5)));
|
__attribute__ ((__format__ (__printf__, 4, 5)));
|
||||||
|
|
||||||
|
|
||||||
|
/** Report an obsolete syntax, suggest the updated one. */
|
||||||
|
void deprecated_directive (location const *loc,
|
||||||
|
char const *obsolete, char const *updated);
|
||||||
|
|
||||||
/** Warnings treated as errors shouldn't stop the execution as regular errors
|
/** Warnings treated as errors shouldn't stop the execution as regular errors
|
||||||
should (because due to their nature, it is safe to go on). Thus, there are
|
should (because due to their nature, it is safe to go on). Thus, there are
|
||||||
three possible execution statuses. */
|
three possible execution statuses. */
|
||||||
|
|||||||
@@ -77,9 +77,7 @@ static size_t no_cr_read (FILE *, char *, size_t);
|
|||||||
#define DEPRECATED(Msg) \
|
#define DEPRECATED(Msg) \
|
||||||
do { \
|
do { \
|
||||||
size_t i; \
|
size_t i; \
|
||||||
complain (loc, Wdeprecated, \
|
deprecated_directive (loc, yytext, Msg); \
|
||||||
_("deprecated directive: %s, use %s"), \
|
|
||||||
quote (yytext), quote_n (1, Msg)); \
|
|
||||||
scanner_cursor.column -= mbsnwidth (Msg, strlen (Msg), 0); \
|
scanner_cursor.column -= mbsnwidth (Msg, strlen (Msg), 0); \
|
||||||
for (i = strlen (Msg); i != 0; --i) \
|
for (i = strlen (Msg); i != 0; --i) \
|
||||||
unput (Msg[i - 1]); \
|
unput (Msg[i - 1]); \
|
||||||
|
|||||||
Reference in New Issue
Block a user