c: no longer require stdio.h when locations are enabled

Recent changes (in 2.7) introduced a dependency on both FILE and
fprintf, which are "available" only in %debug mode.  This was to
define yy_location_print_, which is used only in %debug mode by the
parser, but massively used by the test suite to output the locations
in yyerror.

Break this dependency: the test suite should define its own routines
to display the locations.  Eventually Bison will provide the user with
a means to display locations, but not yet.

* data/c.m4 (b4_yy_location_print_define): Use YYFPRINTF instead of
fprintf directly.
* data/yacc.c (b4_yy_location_print_define): Invoke it only in %debug
mode, so that stdio.h is included (needed for FILE*), and YYFPRINTF
is defined.

* tests/local.at (AT_YYERROR_DECLARE, AT_YYERROR_DEFINE): Declare
and define location_print and LOCATION_PRINT.

* tests/actions.at, tests/existing.at, tests/glr-regression.at,
* tests/input.at, tests/named-refs.at, tests/regression.at: Adjust
to use them.
Fix the expected line numbers (as the prologue's length has changed).
This commit is contained in:
Akim Demaille
2013-01-25 13:51:33 +01:00
parent d9fa1b7c4f
commit f0f95a50ee
11 changed files with 147 additions and 96 deletions

View File

@@ -1643,10 +1643,10 @@ sym3: %merge<merge> { $$ = 0; } ;
AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([[-o glr-regr18.c glr-regr18.y]], 1, [],
[[glr-regr18.y:26.18-24: error: result type clash on merge function 'merge': <type2> != <type1>
glr-regr18.y:25.18-24: previous declaration
glr-regr18.y:27.13-19: error: result type clash on merge function 'merge': <type3> != <type2>
glr-regr18.y:26.18-24: previous declaration
[[glr-regr18.y:28.18-24: error: result type clash on merge function 'merge': <type2> != <type1>
glr-regr18.y:27.18-24: previous declaration
glr-regr18.y:29.13-19: error: result type clash on merge function 'merge': <type3> != <type2>
glr-regr18.y:28.18-24: previous declaration
]])
AT_CLEANUP
@@ -1699,14 +1699,14 @@ Entering state 1
Reading a token: Next token is token 'b' ()
Shifting token 'b' ()
Entering state 3
Reducing stack 0 by rule 3 (line 25):
Reducing stack 0 by rule 3 (line 27):
$1 = token 'b' ()
-> $$ = nterm b ()
Entering state 4
Reading a token: Next token is token 'c' ()
Shifting token 'c' ()
Entering state 6
Reducing stack 0 by rule 4 (line 26):
Reducing stack 0 by rule 4 (line 28):
-> $$ = nterm d ()
Entering state 7
Reading a token: Now at end of input.