Fix test failure reported by Tom Lane in
[bison.git] / tests / regression.at
index 666b99e54401e889568562fba409b30ea209e073..40a18080b02a2188292f53fa1336b55dbfed8b5c 100644 (file)
@@ -434,6 +434,7 @@ AT_SETUP([Token definitions])
 # Bison managed, when fed with `%token 'f' "f"' to #define 'f'!
 AT_DATA_GRAMMAR([input.y],
 [%{
+#include <stdlib.h>
 #include <stdio.h>
 void yyerror (const char *s);
 int yylex (void);
@@ -457,6 +458,9 @@ yyerror (char const *s)
 int
 yylex (void)
 {
+  static int called;
+  if (called++)
+    abort ();
   return SPECIAL;
 }
 
@@ -822,7 +826,8 @@ m4_define([_AT_DATA_DANCER_Y],
 [%{
 static int yylex (AT_LALR1_CC_IF([int *], [void]));
 AT_LALR1_CC_IF([],
-[#include <stdio.h>
+[#include <stdlib.h>
+#include <stdio.h>
 static void yyerror (const char *);])
 %}
 $1
@@ -896,12 +901,14 @@ yyerror (const char *s)
 static int
 yylex (AT_LALR1_CC_IF([int *lval], [void]))
 [{
-  static int toknum = 0;
-  static int tokens[] =
+  static int const tokens[] =
     {
       ':', -1
     };
+  static size_t toknum;
   ]AT_LALR1_CC_IF([*lval = 0; /* Pacify GCC.  */])[
+  if (! (toknum < sizeof tokens / sizeof *tokens))
+    abort ();
   return tokens[toknum++];
 }]
 
@@ -993,12 +1000,14 @@ yyerror (const char *s)
 static int
 yylex (AT_LALR1_CC_IF([int *lval], [void]))
 [{
-  static int toknum = 0;
-  static int tokens[] =
+  static int const tokens[] =
     {
       1000, '+', '+', -1
     };
+  static size_t toknum;
   ]AT_LALR1_CC_IF([*lval = 0; /* Pacify GCC.  */])[
+  if (! (toknum < sizeof tokens / sizeof *tokens))
+    abort ();
   return tokens[toknum++];
 }]