mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-15 23:33:03 +00:00
* src/reader.c (grammar_midrule_action): If $$ is set in a
mid-rule, move the `used' bit to its lhs. * tests/input.at (Unused values): New. * tests/actions.at (Exotic Dollars): Adjust: exp is not typed.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# Executing Actions. -*- Autotest -*-
|
||||
# Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001, 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
|
||||
@@ -107,7 +107,7 @@ AT_DATA_GRAMMAR([[input.y]],
|
||||
};
|
||||
|
||||
%type <val> a_1 a_2 a_5
|
||||
exp sum_of_the_five_previous_values
|
||||
sum_of_the_five_previous_values
|
||||
|
||||
%%
|
||||
exp: a_1 a_2 { $<val>$ = 3; } { $<val>$ = $<val>3 + 1; } a_5
|
||||
@@ -146,7 +146,7 @@ main (void)
|
||||
}
|
||||
]])
|
||||
|
||||
AT_CHECK([bison -d -v -o input.c input.y], 0, [],
|
||||
AT_CHECK([bison -d -v -o input.c input.y], 0, [],
|
||||
[input.y:30.6-34.5: warning: unused value: $1
|
||||
input.y:30.6-34.5: warning: unused value: $2
|
||||
input.y:30.6-34.5: warning: unused value: $5
|
||||
|
||||
@@ -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. ##
|
||||
## ---------------------- ##
|
||||
|
||||
Reference in New Issue
Block a user