Bison 3.8 now emits a prototype for `yyerror`:¹
To comply with the latest POSIX standard, in Yacc compatibility mode
(options `-y`/`--yacc`) Bison now generates prototypes for yyerror and
yylex. In some situations, this is breaking compatibility: if the user
has already declared these functions but with some differences (e.g., to
declare them as static, or to use specific attributes), the generated
parser will fail to compile. To disable these prototypes, #define yyerror
(to `yyerror`), and likewise for yylex.
Because the generated prototype takes a const parameter,² this prototype
conflicts with the implementation in dotlex.c causing a compilation error.
Rather than the work around suggested by the Bison notes, this change simply
re-aligns `yyerror` with the Bison default.
Fixed #2127.
¹ https://github.com/akimd/bison/blob/master/NEWS
² https://www.gnu.org/software/bison/manual/html_node/Error-Reporting-Function.html
- Ensure correct file-level dependency for generated file in cmake generated
projects #2119
- compile failures with a C++20-compatible toolchain #2122
+- compile errors on macOS when using Bison 3.8 #2127
## [2.49.0] – 2021-08-28
return token;
}
-void
-yyerror (char *fmt, char *s) {
+static void yyerror_text(const char *fmt, const char *s) {
if (syntax_errors++)
return;
fprintf (stderr, "graph parser: ");
error_context ();
}
+void yyerror(const char *message) {
+ yyerror_text(message, "");
+}
+
static char *lex_gets (int curlen) {
char *clp;
int len;
}
*q = '\0';
if (saw_digit && *z && (isalpha (*z)))
- yyerror ("badly formed number %s", lexbuf);
+ yyerror_text("badly formed number %s", lexbuf);
if (saw_digit == FALSE)
z = NULL;
*q++ = *p++;
}
if (strcmp(p, "") == 0)
- yyerror ("string ran past end of line", "");
+ yyerror("string ran past end of line");
else
p++;
*q = 0;
static char portstr[SMALLBUF];
-extern void yyerror(const char *fmt, ...);
+extern void yyerror(const char *message);
%}
%union {