yacc: declare yyerror/yylex only when POSIXLY_CORRECT

The recent changes to comply with POSIX are breaking Automake's test
suite.
Reported by Kiyoshi Kanazawa.
<https://lists.gnu.org/r/bug-bison/2021-09/msg00005.html>

To limit the impact of POSIX changes, bind them to $POSIXLY_CORRECT.
Suggested by Karl Berry.
<https://lists.gnu.org/r/bug-bison/2021-09/msg00009.html>

The existing `maintainer-check-posix` Make target checks these
changes.

* src/getargs.h, src/getargs.c (set_yacc): New.
Use it.
* data/skeletons/bison.m4 (b4_posix_if): New.
* data/skeletons/yacc.c (b4_declare_yyerror_and_yylex): Use it.
* doc/bison.texi, tests/local.at: Adjust.
This commit is contained in:
Akim Demaille
2021-09-10 06:48:02 +02:00
parent ad9b8a069f
commit 5d9ccd5a87
11 changed files with 53 additions and 16 deletions

10
NEWS
View File

@@ -2,6 +2,14 @@ GNU Bison NEWS
* Noteworthy changes in release ?.? (????-??-??) [?]
The generation of prototypes for yylex and yyerror in Yacc mode is
breaking existing grammar files. To avoid breaking too many grammars, the
prototypes are now generated when `-y/--yacc` is used *and* the
`POSIXLY_CORRECT` environment variable is defined.
Avoid using `-y`/`--yacc` simply to comply with Yacc's file name
conventions, rather, use `-o y.tab.c`. Autoconf's AC_PROG_YACC macro uses
`-y`. Avoid it if possible, for instance by using gnulib's gl_PROG_BISON.
* Noteworthy changes in release 3.8 (2021-09-07) [stable]
@@ -4706,7 +4714,7 @@ LocalWords: autocompletion bistromathic submessages Cayuela lexcalc hoc
LocalWords: yytoken YYUNDEF YYerror basename Automake's UTF ifdef ffile
LocalWords: gotos readline Imbimbo Wcounterexamples Wcex Nonunifying rcex
LocalWords: Vais xsltproc YYNOMEM YYLOCATION signedness YYBISON MITRE's
LocalWords: libreadline YYMALLOC YYFREE MSVC redefinitions
LocalWords: libreadline YYMALLOC YYFREE MSVC redefinitions POSIXLY
Local Variables:
ispell-dictionary: "american"