summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel E. Denny <jdenny@clemson.edu>2011-05-01 21:53:35 -0400
committerJoel E. Denny <jdenny@clemson.edu>2011-05-01 23:13:13 -0400
commit1f36f54446248b8984b9c378b0c756a6b51b34cb (patch)
tree007debbf69f6f7c823cdd6b9c1e9e9e8a42df59e
parentba60c39547a445dee3e07920931b4d7a81843868 (diff)
downloadbison-1f36f54446248b8984b9c378b0c756a6b51b34cb.tar.gz
Fix precedence for end token.
Since Bison 2.3b, which restored the ability of precedence directives to assign user token numbers, doing so for user token number 0 has produced an assertion failure. * NEWS (2.5): Document fix. * src/symtab.c (symbol_user_token_number_set): In the case of the end token, don't decrement ntokens if it was never incremented. * tests/regression.at (Token number in precedence declaration): Extend. (cherry picked from commit 9d6af153184eea964fef7f87d76a60fe29f715b5)
-rw-r--r--ChangeLog12
-rw-r--r--NEWS10
-rw-r--r--src/symtab.c5
-rw-r--r--tests/regression.at10
4 files changed, 32 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 77641bd5..595f782d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
2011-05-01 Joel E. Denny <joeldenny@joeldenny.org>
+ Fix precedence for end token.
+ Since Bison 2.3b, which restored the ability of precedence
+ directives to assign user token numbers, doing so for user token
+ number 0 has produced an assertion failure.
+ * NEWS (2.5): Document fix.
+ * src/symtab.c (symbol_user_token_number_set): In the case of the
+ end token, don't decrement ntokens if it was never incremented.
+ * tests/regression.at (Token number in precedence declaration):
+ Extend.
+
+2011-05-01 Joel E. Denny <joeldenny@joeldenny.org>
+
Pacify -DGNULIB_POSIXCHECK.
* bootstrap.conf (gnulib_modules): Add all modules suggested by
-DGNULIB_POSIXCHECK.
diff --git a/NEWS b/NEWS
index 989e6b8b..3b225121 100644
--- a/NEWS
+++ b/NEWS
@@ -402,6 +402,16 @@ Bison News
bison -Wnone gram.y
+** Precedence directives can now assign token number 0:
+
+ Since Bison 2.3b, which restored the ability of precedence
+ directives to assign token numbers, doing so for token number 0 has
+ produced an assertion failure. For example:
+
+ %left END 0
+
+ This bug has been fixed.
+
* Changes in version 2.4.3 (2010-08-05):
** Bison now obeys -Werror and --warnings=error for warnings about
diff --git a/src/symtab.c b/src/symtab.c
index 87a9618e..d22743f1 100644
--- a/src/symtab.c
+++ b/src/symtab.c
@@ -403,10 +403,11 @@ symbol_user_token_number_set (symbol *sym, int user_token_number, location loc)
if (user_token_number == 0)
{
endtoken = sym;
- endtoken->number = 0;
/* It is always mapped to 0, so it was already counted in
NTOKENS. */
- --ntokens;
+ if (endtoken->number != NUMBER_UNDEFINED)
+ --ntokens;
+ endtoken->number = 0;
}
}
diff --git a/tests/regression.at b/tests/regression.at
index 5e0ead03..b4470d54 100644
--- a/tests/regression.at
+++ b/tests/regression.at
@@ -1196,12 +1196,15 @@ AT_DATA_GRAMMAR([input.y],
%}
%error-verbose
+%right END 0
%left TK1 1 TK2 2 "tok alias" 3
%%
-start: TK1 sr_conflict "tok alias" ;
-
+start:
+ TK1 sr_conflict "tok alias"
+ | start %prec END
+ ;
sr_conflict:
TK2
| TK2 "tok alias"
@@ -1231,7 +1234,8 @@ main (void)
]])
AT_BISON_CHECK([[-o input.c input.y]], [[0]],,
-[[input.y:24.5-19: warning: rule useless in parser due to conflicts: sr_conflict: TK2 "tok alias"
+[[input.y:23.5-19: warning: rule useless in parser due to conflicts: start: start
+input.y:27.5-19: warning: rule useless in parser due to conflicts: sr_conflict: TK2 "tok alias"
]])
AT_COMPILE([[input]])
AT_PARSER_CHECK([[./input]])