[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Regression 2.0 related to symbol aliases
From: |
Tim Van Holder |
Subject: |
Regression 2.0 related to symbol aliases |
Date: |
Tue, 12 Apr 2005 15:19:42 +0200 |
User-agent: |
Mozilla Thunderbird 1.0 (Windows/20041206) |
Revision 1.57 of src/symtab.c removed a symbol_type_set() call
from symbol_make_alias() (without altering that function's
descriptive comment, by the way). symbol_type_set() calls were
added to symbol_check_alias_consistency(), presumably to make
up for that removal. However, symbol_check_alias_consistency()
isn't called (via symbols_pack()) until the grammar file has been
completely, and the symbol type info is used during that parse.
As a result, aliases for typed symbols are completely broken in
bison 2.0. The patch below restores the symbol_make_alias()
behavior, and avoids type redeclaration errors in
symbol_check_alias_consistency().
I also added a simplistic test.
Index: src/symtab.c
===================================================================
RCS file: /cvsroot/bison/bison/src/symtab.c,v
retrieving revision 1.59
diff -u -u -p -d -r1.59 src/symtab.c
--- src/symtab.c 16 Dec 2004 00:08:21 -0000 1.59
+++ src/symtab.c 12 Apr 2005 13:12:03 -0000
@@ -264,6 +264,7 @@ symbol_make_alias (symbol *sym, symbol *
abort ();
sym->number = symval->number =
(symval->number < sym->number) ? symval->number : sym->number;
+ symbol_type_set (symval, sym->type_name, loc);
}
}
@@ -285,10 +286,14 @@ symbol_check_alias_consistency (symbol *
if (orig->type_name || alias->type_name)
{
- if (orig->type_name)
- symbol_type_set (alias, orig->type_name, orig->type_location);
- else
- symbol_type_set (orig, alias->type_name, alias->type_location);
+ if (!(orig->type_name && alias->type_name)
+ || orig->type_name != alias->type_name)
+ {
+ if (orig->type_name)
+ symbol_type_set (alias, orig->type_name, orig->type_location);
+ else
+ symbol_type_set (orig, alias->type_name, alias->type_location);
+ }
}
--- input.at 12 Apr 2005 13:44:39 +0200 1.30
+++ input.at 12 Apr 2005 15:19:47 +0200
@@ -272,3 +272,28 @@ AT_PARSER_CHECK([./input], 0,
]])
AT_CLEANUP
+
+
+## ---------------------- ##
+## Typed symbol aliases. ##
+## ---------------------- ##
+
+AT_SETUP([Typed symbol aliases])
+
+# Bison 2.0 broke typed symbol aliases - ensure they work.
+
+AT_DATA_GRAMMAR([input.y],
+[[%union
+{
+ int val;
+};
+%token <val> MY_TOKEN "MY TOKEN"
+%type <val> exp
+%%
+exp: "MY TOKEN";
+%%
+]])
+
+AT_CHECK([bison -o input.c input.y])
+
+AT_CLEANUP
- Regression 2.0 related to symbol aliases,
Tim Van Holder <=