From fc01665ea5901b1d426ab3637a26dff9a8ff87e4 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 25 Jul 2005 03:38:42 +0000 Subject: [PATCH] Fix core dump reported by Pablo De Napoli in . * tests/regression.at (Invalid inputs with {}): New test. * src/parse-gram.y (token_name): Translate type before using it as an index. --- ChangeLog | 6 ++++++ src/parse-gram.y | 2 +- tests/regression.at | 21 +++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 6b30ded8..ddee4aa6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,12 @@ * NEWS: Version 2.0b. + Fix core dump reported by Pablo De Napoli in + . + * tests/regression.at (Invalid inputs with {}): New test. + * src/parse-gram.y (token_name): Translate type before using + it as an index. + * data/glr.c (ATTRIBUTE_UNUSED): Remove, since it infringes on the user's name space. All uses changed to __attribute__ ((__unused__)). diff --git a/src/parse-gram.y b/src/parse-gram.y index a638cb06..db15562d 100644 --- a/src/parse-gram.y +++ b/src/parse-gram.y @@ -538,5 +538,5 @@ gram_error (location const *loc, char const *msg) char const * token_name (int type) { - return yytname[type]; + return yytname[YYTRANSLATE (type)]; } diff --git a/tests/regression.at b/tests/regression.at index 5ee3da93..de62cdcc 100644 --- a/tests/regression.at +++ b/tests/regression.at @@ -303,6 +303,27 @@ input.y:7.1-8.0: missing `%}' at end of file AT_CLEANUP +AT_SETUP([Invalid inputs with {}]) + +AT_DATA([input.y], +[[ +%destructor +%initial-action +%lex-param +%parse-param +%printer +%union +]]) + +AT_CHECK([bison input.y], [1], [], +[[input.y:3.1: missing `{' in "%destructor {...}" +input.y:4.1: missing `{' in "%initial-action {...}" +input.y:4.1: syntax error, unexpected %initial-action {...}, expecting string or identifier +]]) + +AT_CLEANUP + + ## ------------------- ## ## Token definitions. ## -- 2.47.2