compile errors on macOS when using Bison 3.8
From the CI logs for a recent run, https://gitlab.com/graphviz/graphviz/-/pipelines/369360035:
[ 35%] [BISON][Exparse] Building parser with bison 3.8
/Users/gitlab/builds/graphviz/graphviz/lib/expr/exparse.y: warning: 4 shift/reduce conflicts [-Wconflicts-sr]
/Users/gitlab/builds/graphviz/graphviz/lib/expr/exparse.y: note: rerun with option '-Wcounterexamples' to generate conflict counterexamples
[ 35%] Generating exparse.c
[ 35%] Building C object lib/expr/CMakeFiles/expr.dir/excc.c.o
In file included from /Users/gitlab/builds/graphviz/graphviz/lib/expr/excc.c:24:
In file included from /Users/gitlab/builds/graphviz/graphviz/lib/expr/exlib.h:126:
/Users/gitlab/builds/graphviz/graphviz/lib/expr/expr.h:274:14: error: conflicting types for 'exerror'
extern void exerror(const char*, ...);
^
/Users/gitlab/builds/graphviz/graphviz/build/lib/expr/y.tab.h:260:6: note: previous declaration is here
void exerror (const char *msg);
^
1 error generated.
and for Autotools:
bison -y -Wno-yacc -dv --output=grammar.c ../../lib/cgraph/grammar.y
CC grammar.lo
In file included from grammar.c:168:
grammar.h:118:6: error: conflicting types for 'aagerror'
void aagerror (const char *msg);
^
../../lib/cgraph/grammar.y:26:13: note: previous declaration is here
extern void aagerror(char *);
^
1 error generated.
make[3]: *** [grammar.lo] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
This appears to be a side effect of Bison 3.8 becoming available in Homebrew, and CI now installing that instead of 3.7.6. The Bison changelog has lots of interesting remarks. In particular:
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.