]> git.saurik.com Git - bison.git/blobdiff - tests/input.at
Merge remote-tracking branch 'origin/maint'
[bison.git] / tests / input.at
index bb37be0a5ee21bcab258572eee9ce30ffe0dc6e7..356fe92b42e90d35e0653116322a1d4ab46f1e1b 100644 (file)
@@ -323,6 +323,51 @@ input.y:5.25-31: warning: type <type4> is used, but is not associated to any sym
 AT_CLEANUP
 
 
+## --------------------------------- ##
+## Useless printers or destructors.  ##
+## --------------------------------- ##
+
+AT_SETUP([Useless printers or destructors])
+
+AT_DATA([[input.y]],
+[[%token <type1> token1
+%token <type2> token2
+%token <type3> token3
+%token <type4> token4
+%token <type5> token51 token52
+%token <type6> token61 token62
+%token <type7> token7
+
+%printer {} token1
+%destructor {} token2
+%printer {} token51
+%destructor {} token61
+
+%printer {} token7
+
+%printer {} <type1>
+%destructor {} <type2>
+%printer {} <type3>
+%destructor {} <type4>
+
+%printer {} <type5>
+%destructor {} <type6>
+
+%destructor {} <type7>
+
+%%
+exp: "a";
+]])
+
+AT_BISON_CHECK([input.y], [0], [],
+[[input.y:16.13-19: warning: useless %printer for type <type1>
+input.y:17.16-22: warning: useless %destructor for type <type2>
+]])
+
+
+AT_CLEANUP
+
+
 ## ---------------------------------------- ##
 ## Unused values with default %destructor.  ##
 ## ---------------------------------------- ##
@@ -488,6 +533,7 @@ char apostrophe = '\'';
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <assert.h>
 %}
 /* %{ and %} can be here too. */
 
@@ -555,8 +601,7 @@ yylex (void)
 #output "; /* "
   */
   static size_t toknum;
-  if (! (toknum < sizeof input))
-    abort ();
+  assert (toknum < sizeof input);
   yylval = value_as_yystype (input[toknum]);
   return input[toknum++];
 }
@@ -579,8 +624,8 @@ main (void)
 AT_BISON_OPTION_POPDEFS
 
 AT_BISON_CHECK([-d -v -o input.c input.y])
-AT_COMPILE([input.o], [-c input.c])
-AT_COMPILE([main.o], [-c main.c])
+AT_COMPILE([input.o])
+AT_COMPILE([main.o])
 AT_COMPILE([input], [input.o main.o])
 AT_PARSER_CHECK([./input], 0,
 [[[@<:@],
@@ -700,7 +745,7 @@ input.y:18.8-16: warning: POSIX Yacc forbids dashes in symbol names: with-dash
 AT_BISON_CHECK([-o input.c input.y])
 
 # Make sure we don't export silly token identifiers with periods or dashes.
-AT_COMPILE([input.o], [-c input.c])
+AT_COMPILE([input.o])
 
 
 # Periods are genuine letters, they can start identifiers.