[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] warnings: used but undeclared symbols are warnings
From: |
Akim Demaille |
Subject: |
Re: [PATCH] warnings: used but undeclared symbols are warnings |
Date: |
Thu, 21 Jun 2012 15:33:00 +0200 |
Le 20 juin 2012 à 22:10, Akim Demaille a écrit :
>
> Le 20 juin 2012 à 11:09, Akim Demaille a écrit :
>
>> Also, and much worse, your patches "degrades" serious errors into
>> simple warnings. This is not acceptable, and unfortunately, this
>> is not caught by the test suite. Please, take the following example,
>> and make it a test.
>>
>> $ cat /tmp/foo.y
>> %printer {} foo;
>> %%
>> exp: 'a';
>
> Sorry, that was 'exp: "foo"'.
>
>> $ LC_ALL=C bison /tmp/foo.y
>> /tmp/foo.y:1.13-15: symbol foo is used, but is not defined as a token and
>> has no rules
>>
>> $ LC_ALL=C ./_build/debug7/tests/bison /tmp/foo.y
>> /tmp/foo.y:1.13-15: warning: symbol foo is used, but is not defined as a
>> token and has no rules
>> /tmp/foo.y: warning: 3 nonterminals useless in grammar
>> /tmp/foo.y: warning: 2 rules useless in grammar
>> /tmp/foo.y:3.1-3: fatal error: start symbol exp does not derive any sentence
>>
>> I should have tested more thoroughly before pushing, sorry. Waiting
>> for your fix.
>
> Here is my proposal.
>
> <0001-fix-warnings-for-useless-printer-destructor.patch>
> From 3b0b682fd6c55c0387aacbb86bc708da09ad2ae3 Mon Sep 17 00:00:00 2001
> From: Akim Demaille <address@hidden>
> Date: Wed, 20 Jun 2012 12:33:34 +0200
> Subject: [PATCH] fix warnings for useless %printer/%destructor
>
> The previous commit, which turns into a warning what used to be an
> error:
>
> %printer {} foo;
> %%
> exp: '0';
>
> has two shortcomings: the warning is way too long (foo is reported
> to be useless later), and besides, it also turns into a warning much
> more serious errors:
>
> %printer {} foo;
> %%
> exp: foo;
>
> Reduce the amount to warnings in the first case, restore the error in
should have read "of warnings".
> the second.
>
> * src/symtab.h (status): Add a new inital state: undeclared.
> * src/symtab.c (symbol_new): Initialize to undeclared.
> (symbol_class_set): Simplify the logic of the code that neutralize
> the "redeclared" warning after the "redefined" one.
> (symbol_check_defined): "undeclared" is also an error.
> * src/reader.c (grammar_current_rule_symbol_append): Symbols appearing
> in a rule are "needed".
> * src/symlist.c (symbol_list_destructor_set, symbol_list_printer_set):
> An unknown symbol appearing in a %printer/%destructor is "used".
> * src/reduce.c (nonterminals_reduce): Do not report as "useless" symbols
> that are not used (e.g., those that for instance appeared only in a
> %printer).
> * tests/input.at (Undeclared symbols used for a printer or destructor):
> Improve the cover the cases described above.
Installed.