[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
redeclarations: say "previous" not "first" declaration
From: |
Joel E. Denny |
Subject: |
redeclarations: say "previous" not "first" declaration |
Date: |
Fri, 7 Jul 2006 17:25:04 -0400 (EDT) |
Well, it bugged me, so I committed this.
Index: ChangeLog
===================================================================
RCS file: /sources/bison/bison/ChangeLog,v
retrieving revision 1.1520
diff -p -u -r1.1520 ChangeLog
--- ChangeLog 7 Jul 2006 19:43:33 -0000 1.1520
+++ ChangeLog 7 Jul 2006 21:23:33 -0000
@@ -1,3 +1,15 @@
+2006-07-07 Joel E. Denny <address@hidden>
+
+ In warnings, say "previous declaration" rather than "first
+ declaration".
+ * src/symtab.c (redeclaration): Do that here.
+ * src/reader.c (record_merge_function_type): In the case of a result
+ type clash, report the previous declaration rather than the very first
+ one in the grammar file.
+ * tests/glr-regression.at (Missed %merge type warnings when LHS type is
+ declared later): Add a third declaration to check this behavior.
+ * tests/input.at (Incompatible Aliases): Update output.
+
2006-06-27 Akim Demaille <address@hidden>
* doc/Doxyfile.in: New.
Index: src/reader.c
===================================================================
RCS file: /sources/bison/bison/src/reader.c,v
retrieving revision 1.262
diff -p -u -r1.262 reader.c
--- src/reader.c 26 Jun 2006 04:45:24 -0000 1.262
+++ src/reader.c 7 Jul 2006 21:23:33 -0000
@@ -146,19 +146,16 @@ record_merge_function_type (int merger,
merge_function = merge_function->next)
merger_find += 1;
assert (merge_function != NULL && merger_find == merger);
- if (merge_function->type == NULL)
- {
- merge_function->type = uniqstr_new (type);
- merge_function->type_declaration_location = declaration_loc;
- }
- else if (!UNIQSTR_EQ (merge_function->type, type))
+ if (merge_function->type != NULL && !UNIQSTR_EQ (merge_function->type, type))
{
warn_at (declaration_loc,
_("result type clash on merge function `%s': <%s> != <%s>"),
merge_function->name, type, merge_function->type);
warn_at (merge_function->type_declaration_location,
- _("first declaration"));
+ _("previous declaration"));
}
+ merge_function->type = uniqstr_new (type);
+ merge_function->type_declaration_location = declaration_loc;
}
/*--------------------------------------.
Index: src/symtab.c
===================================================================
RCS file: /sources/bison/bison/src/symtab.c,v
retrieving revision 1.72
diff -p -u -r1.72 symtab.c
--- src/symtab.c 22 Jun 2006 19:46:05 -0000 1.72
+++ src/symtab.c 7 Jul 2006 21:23:33 -0000
@@ -108,7 +108,7 @@ static void
redeclaration (symbol* s, const char *what, location first, location second)
{
complain_at (second, _("%s redeclaration for %s"), what, s->tag);
- complain_at (first, _("first declaration"));
+ complain_at (first, _("previous declaration"));
}
Index: tests/glr-regression.at
===================================================================
RCS file: /sources/bison/bison/tests/glr-regression.at,v
retrieving revision 1.37
diff -p -u -r1.37 glr-regression.at
--- tests/glr-regression.at 26 Jun 2006 04:45:24 -0000 1.37
+++ tests/glr-regression.at 7 Jul 2006 21:23:33 -0000
@@ -1679,15 +1679,18 @@ AT_DATA_GRAMMAR([glr-regr18.y],
%union {
int type1;
int type2;
+ int type3;
}
%%
sym1: sym2 %merge<merge> { $$ = $1; } ;
-sym2: %merge<merge> { $$ = 0; } ;
+sym2: sym3 %merge<merge> { $$ = $1; } ;
+sym3: %merge<merge> { $$ = 0; } ;
%type <type1> sym1;
%type <type2> sym2;
+%type <type3> sym3;
%%
@@ -1711,8 +1714,10 @@ main (void)
]])
AT_CHECK([[bison -o glr-regr18.c glr-regr18.y]], 0, [],
-[glr-regr18.y:26.13-19: warning: result type clash on merge function `merge':
<type2> != <type1>
-glr-regr18.y:25.18-24: warning: first declaration
+[glr-regr18.y:27.18-24: warning: result type clash on merge function `merge':
<type2> != <type1>
+glr-regr18.y:26.18-24: warning: previous declaration
+glr-regr18.y:28.13-19: warning: result type clash on merge function `merge':
<type3> != <type2>
+glr-regr18.y:27.18-24: warning: previous declaration
])
AT_CLEANUP
Index: tests/input.at
===================================================================
RCS file: /sources/bison/bison/tests/input.at,v
retrieving revision 1.47
diff -p -u -r1.47 input.at
--- tests/input.at 26 Jun 2006 04:16:50 -0000 1.47
+++ tests/input.at 7 Jul 2006 21:23:33 -0000
@@ -193,13 +193,13 @@ exp: foo;
AT_CHECK([bison input.y], [1], [],
[[input.y:8.7-11: %type redeclaration for foo
-input.y:3.7-11: first declaration
+input.y:3.7-11: previous declaration
input.y:10.13-17: %destructor redeclaration for foo
-input.y:5.13-17: first declaration
+input.y:5.13-17: previous declaration
input.y:9.10-14: %printer redeclaration for foo
-input.y:4.10-14: first declaration
+input.y:4.10-14: previous declaration
input.y:11.1-5: %left redeclaration for foo
-input.y:6.1-5: first declaration
+input.y:6.1-5: previous declaration
]])
AT_CLEANUP
- redeclarations: say "previous" not "first" declaration,
Joel E. Denny <=
- Re: redeclarations: say "previous" not "first" declaration, Akim Demaille, 2006/07/08
- Re: redeclarations: say "previous" not "first" declaration, Joel E. Denny, 2006/07/08
- Re: redeclarations: say "previous" not "first" declaration, Akim Demaille, 2006/07/08
- Re: redeclarations: say "previous" not "first" declaration, Joel E. Denny, 2006/07/08
- Re: redeclarations: say "previous" not "first" declaration, Akim Demaille, 2006/07/09
- Re: redeclarations: say "previous" not "first" declaration, Joel E. Denny, 2006/07/09
- Re: redeclarations: say "previous" not "first" declaration, Joel E. Denny, 2006/07/09