AT_CLEANUP
+## ----------------------------------------------------- ##
+## Undeclared symbols used for a printer or destructor. ##
+## ----------------------------------------------------- ##
+
+AT_SETUP([Undeclared symbols used for a printer or destructor])
+
+AT_DATA([[input.y]],
+[[%printer {} foo baz
+%destructor {} bar
+
+%%
+exp: bar;
+]])
+
+AT_BISON_CHECK([input.y], [1], [],
+[[input.y:2.16-18: symbol bar is used, but is not defined as a token and has no rules
+input.y:1.17-19: warning: symbol baz is used, but is not defined as a token and has no rules
+input.y:1.13-15: warning: symbol foo is used, but is not defined as a token and has no rules
+]])
+
+AT_CLEANUP
+
## ---------------------------------------- ##
## Unused values with default %destructor. ##
AT_SETUP([Torturing the Scanner])
-
+AT_BISON_OPTION_PUSHDEFS
AT_DATA([input.y], [])
AT_BISON_CHECK([input.y], [1], [],
[[input.y:1.1: syntax error, unexpected end of file
%}
%{
-static void yyerror (const char *s);
-static int yylex (void);
+]AT_YYERROR_DECLARE[
+]AT_YYLEX_DECLARE[
%}
%type <ival> '@<:@'
res.ival = val;
return res;
}
-
+]AT_YYERROR_DEFINE[
static int
yylex (void)
{
yylval = value_as_yystype (input[toknum]);
return input[toknum++];
}
-
-static void
-yyerror (const char *msg)
-{
- fprintf (stderr, "%s\n", msg);
-}
]])
# Pacify Emacs'font-lock-mode: "
return yyparse ();
}
]])
+AT_BISON_OPTION_POPDEFS
AT_BISON_CHECK([-d -v -o input.c input.y])
AT_COMPILE([input.o], [-c input.c])
AT_SETUP([Symbols])
+AT_BISON_OPTION_PUSHDEFS
AT_DATA_GRAMMAR([input.y],
[[%token WITH-DASH
%token WITHOUT_DASH "WITHOUT-DASH"
%token WITH.PERIOD
%token WITHOUT_PERIOD "WITHOUT.PERIOD"
%code {
- void yyerror (char const *);
- int yylex (void);
+ ]AT_YYERROR_DECLARE[
+ ]AT_YYLEX_DECLARE[
}
%%
start: with-dash without_dash with.period without_period;
with.period: WITH.PERIOD;
without_period: "WITHOUT.PERIOD";
%%
+]AT_YYERROR_DEFINE[
+]AT_YYLEX_DEFINE[
]])
+AT_BISON_OPTION_POPDEFS
# POSIX Yacc accept periods, but not dashes.
AT_BISON_CHECK([--yacc input.y], [1], [],