]> git.saurik.com Git - bison.git/commitdiff
When a literal string is used to define two different tokens,
authorAkim Demaille <akim@epita.fr>
Wed, 4 Oct 2000 11:52:53 +0000 (11:52 +0000)
committerAkim Demaille <akim@epita.fr>
Wed, 4 Oct 2000 11:52:53 +0000 (11:52 +0000)
`bison -v' segfaults.
Reported by Piotr Gackiewicz, and fixed by Neil Booth.
* tests/regression.m4: New file.
Include the core of the sample provided by Piotr Gackiewicz.
* src/reader.c (parse_token_decl): Diagnose bad cases, and proceed
properly.

ChangeLog
THANKS
src/reader.c
tests/Makefile.am
tests/regression.m4 [new file with mode: 0644]
tests/suite.m4

index 7a28f3d29e3179f863707fe8baa37c3f99088d03..2706577c304f67dacf65a713f57e7a77292fce28 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2000-10-04  Akim Demaille  <akim@epita.fr>
+
+       When a literal string is used to define two different tokens,
+       `bison -v' segfaults.
+       Reported by Piotr Gackiewicz, and fixed by Neil Booth.
+
+       * tests/regression.m4: New file.
+       Include the core of the sample provided by Piotr Gackiewicz.
+       * src/reader.c (parse_token_decl): Diagnose bad cases, and proceed
+       properly.
+
 2000-10-04  Akim Demaille  <akim@epita.fr>
 
        * src/reader.c (parse_expect_decl): Keep `count' within the size
diff --git a/THANKS b/THANKS
index 239ffb64dc547d668fae42a7bb75eba657ce84c0..5aa7039a1150c0452f276853d0210737c8227039 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -5,6 +5,7 @@ Jim Meyering            meyering@gnu.org
 Neil Booth             NeilB@earthling.net
 Noah Friedman                  friedman@gnu.org
 Paul Eggert            eggert@twinsun.com
+Piotr Gackiewicz       gacek@intertel.com.pl
 Richard Stallman       rms@gnu.org
 
 Many people are not named here because we lost track of them.  We
index e4ba16c88f911bf26dec1931d2091ea4f706e60a..4309cf879999a6382b8ccb265176954543d5ac98 100644 (file)
@@ -372,17 +372,25 @@ parse_token_decl (symbol_class what_is, symbol_class what_is_not)
        }
       else if (token == IDENTIFIER && *symval->tag == '\"' && symbol)
        {
+         if (symval->alias)
+           warn (_("symbol `%s' used more than once as a literal string"),
+                 symval->tag);
+         else if (symbol->alias)
+           warn (_("symbol `%s' given more than one literal string"),
+                 symbol->tag);
+         else
+           {
+             symval->class = token_sym;
+             symval->type_name = typename;
+             symval->user_token_number = symbol->user_token_number;
+             symbol->user_token_number = SALIAS;
+             symval->alias = symbol;
+             symbol->alias = symval;
+             /* symbol and symval combined are only one symbol */
+             nsyms--;
+           }
          translations = 1;
-         symval->class = token_sym;
-         symval->type_name = typename;
-         symval->user_token_number = symbol->user_token_number;
-         symbol->user_token_number = SALIAS;
-
-         symval->alias = symbol;
-         symbol->alias = symval;
-         symbol = NULL;
-
-         nsyms--;              /* symbol and symval combined are only one symbol */
+         symbol = NULL;
        }
       else if (token == IDENTIFIER)
        {
index 9560ecd124cdd9085f40f467fce4b21cdc888d59..2f2be974e739be445cc96ba00acb2082b97dce1c 100644 (file)
@@ -21,7 +21,7 @@
 # Distribute the testsuite since GNU M4 is needed to build it.
 noinst_SCRIPTS = testsuite
 
-SUITE = calc.m4
+SUITE = calc.m4 regression.m4
 
 EXTRA_DIST = atgeneral.m4 suite.m4 $(SUITE)
 
diff --git a/tests/regression.m4 b/tests/regression.m4
new file mode 100644 (file)
index 0000000..94839ae
--- /dev/null
@@ -0,0 +1,26 @@
+#                                                        -*- Autoconf -*-
+
+cat <<EOF
+
+Regression tests.
+
+EOF
+
+AT_SETUP(Duplicate string)
+
+AT_DATA([duplicate.y],
+[[/* `Bison -v' used to dump core when two tokens are defined with the same
+   string, as LE and GE below. */
+
+%token NUM
+%token LE "<="
+%token GE "<="
+
+%%
+exp: '(' exp ')' | NUM ;
+%%
+]])
+
+AT_CHECK([bison -v duplicate.y -o duplicate.c], 0, ignore, ignore)
+
+AT_CLEANUP(duplicate.*)
index 61c22e5b5af17fef0a7b6e1173d2b303e0a70498..02864ed4a8eb54e1df608bf5b3da562a47531851 100644 (file)
@@ -5,3 +5,4 @@
 AT_INIT([bison])
 
 AT_INCLUDE([calc.m4])
+AT_INCLUDE([regression.m4])