]> git.saurik.com Git - bison.git/blobdiff - tests/input.at
* src/reader.c (grammar_midrule_action): If $$ is set in a
[bison.git] / tests / input.at
index 99946e9da1e60c57c6c5b4904ae00c40a8f0185f..f533ef3a49dd0dd0fcd720a0d3989f2934af4617 100644 (file)
@@ -1,5 +1,5 @@
 # Checking the Bison scanner.                    -*- Autotest -*-
-# Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -82,6 +82,57 @@ input.y:6.5: warning: empty rule for typed nonterminal, and no action
 AT_CLEANUP
 
 
+## --------------- ##
+## Unused values.  ##
+## --------------- ##
+
+AT_SETUP([Unused values])
+
+AT_DATA([input.y],
+[[%token <integer> INT
+%type <integer> exp
+%%
+exp:
+  INT { } INT { } INT { }
+/* Ideally we would like to complain also about $2 and $4 here, but
+   it's hard to implement.  */
+| INT { $$ } INT { $$ } INT { }
+| INT { $1 } INT { } INT { }
+| INT { } INT { $1 } INT { }
+| INT { } INT {  } INT { $1 }
+| INT { } INT {  } INT { $$ = $1 + $3 + $5; }
+;
+]])
+
+AT_CHECK([bison input.y], [], [],
+[[input.y:5.3-25: warning: unset value: $$
+input.y:5.3-25: warning: unused value: $1
+input.y:5.3-25: warning: unused value: $3
+input.y:5.3-25: warning: unused value: $5
+input.y:8.3-31: warning: unset value: $$
+input.y:8.3-31: warning: unused value: $1
+input.y:8.3-31: warning: unused value: $3
+input.y:8.3-31: warning: unused value: $5
+input.y:9.3-28: warning: unset value: $$
+input.y:9.3-28: warning: unused value: $3
+input.y:9.3-28: warning: unused value: $5
+input.y:10.3-28: warning: unset value: $$
+input.y:10.3-28: warning: unused value: $3
+input.y:10.3-28: warning: unused value: $5
+input.y:11.3-29: warning: unset value: $$
+input.y:11.3-29: warning: unused value: $3
+input.y:11.3-29: warning: unused value: $5
+input.y: conflicts: 1 reduce/reduce
+input.y:8.7-12: warning: rule never reduced because of conflicts: @3: /* empty */
+input.y:9.7-12: warning: rule never reduced because of conflicts: @5: /* empty */
+input.y:10.7-9: warning: rule never reduced because of conflicts: @7: /* empty */
+input.y:11.7-9: warning: rule never reduced because of conflicts: @9: /* empty */
+input.y:12.7-9: warning: rule never reduced because of conflicts: @11: /* empty */
+]])
+
+AT_CLEANUP
+
+
 ## ---------------------- ##
 ## Incompatible Aliases.  ##
 ## ---------------------- ##