# 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
AT_CLEANUP
+## --------------- ##
+## Unused values. ##
+## --------------- ##
+
+m4_define([AT_CHECK_UNUSED_VALUES],
+[AT_SETUP([Unused values])
+
+AT_DATA([input.y],
+[[%token <integer> INT
+%type <integer> exp
+%%
+exp:
+ $1
+| INT
+;
+]])
+
+AT_CHECK([bison input.y], [], [],
+[[$2]])
+
+AT_CLEANUP
+])
+
+AT_CHECK_UNUSED_VALUES([INT { } INT { } INT { }],
+[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
+])
+
+AT_CHECK_UNUSED_VALUES([INT { $1 } INT { } INT { }],
+[input.y:5.3-28: warning: unset value: $$
+input.y:5.3-28: warning: unused value: $3
+input.y:5.3-28: warning: unused value: $5
+])
+
+AT_CHECK_UNUSED_VALUES([INT { } INT { $1 } INT { }],
+[input.y:5.3-28: warning: unset value: $$
+input.y:5.3-28: warning: unused value: $3
+input.y:5.3-28: warning: unused value: $5
+])
+
+AT_CHECK_UNUSED_VALUES([INT { } INT { } INT { $1 }],
+[input.y:5.3-29: warning: unset value: $$
+input.y:5.3-29: warning: unused value: $3
+input.y:5.3-29: warning: unused value: $5
+])
+
+AT_CHECK_UNUSED_VALUES([INT { } INT { } INT { $$ = $1 + $3 + $5; }])
+
+# Checking mid-rule values.
+AT_CHECK_UNUSED_VALUES([INT { $$ } INT { $$ } INT { }],
+[input.y:5.3-31: warning: unset value: $$
+input.y:5.3-31: warning: unused value: $1
+input.y:5.3-31: warning: unused value: $2
+input.y:5.3-31: warning: unused value: $3
+input.y:5.3-31: warning: unused value: $4
+input.y:5.3-31: warning: unused value: $5
+])
+
+AT_CHECK_UNUSED_VALUES([INT { $$ } INT { $$ = $2 } INT { }],
+[input.y:5.3-36: warning: unset value: $$
+input.y:5.3-36: warning: unused value: $1
+input.y:5.3-36: warning: unused value: $3
+input.y:5.3-36: warning: unused value: $4
+input.y:5.3-36: warning: unused value: $5
+])
+
+# AT_CHECK_UNUSED_VALUES([INT { $$ } { $$ = $2 } { }],
+# [input.y:5.3-36: warning: unset value: $$
+# input.y:5.3-36: warning: unused value: $1
+# input.y:5.3-36: warning: unused value: $3
+# input.y:5.3-36: warning: unused value: $4
+# input.y:5.3-36: warning: unused value: $5
+# ])
+
+AT_CHECK_UNUSED_VALUES([INT { $$ = $1 } INT { $$ = $2 + $3 } INT { $$ = $4 + $5 }])
+
+
+
## ---------------------- ##
## Incompatible Aliases. ##
## ---------------------- ##
AT_CHECK([bison -o input.c input.y])
AT_CLEANUP
+
+
+## --------- ##
+## Require. ##
+## --------- ##
+
+m4_define([AT_CHECK_REQUIRE],
+[AT_SETUP([Require $1])
+AT_DATA_GRAMMAR([input.y],
+[[%require "$1";
+%%
+empty_file:;
+]])
+AT_CHECK([bison -o input.c input.y], $2, [], ignore)
+AT_CLEANUP
+])
+
+AT_CHECK_REQUIRE(1.0, 0)
+AT_CHECK_REQUIRE(AT_PACKAGE_VERSION, 0)
+## FIXME: Some day augment this version number.
+AT_CHECK_REQUIRE(100.0, 63)