[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] warnings: introduced -Wprecedence
From: |
Akim Demaille |
Subject: |
Re: [PATCH] warnings: introduced -Wprecedence |
Date: |
Wed, 30 Jan 2013 11:59:53 +0100 |
Le 30 janv. 2013 à 11:33, Valentin Tolmer <address@hidden> a écrit :
> The new warning category precedence is used for useless precedence and
> associativity reporting.
>
> * src/complain.c src/complain.h src/getargs.c : Introduce precedence warning.
Use ", " to separate, no space before ":". Provide more
details on what was introduced.
> * doc/bison.texi : Document the warnings and provide an example.
> * tests/conflicts.at tests/existing.at tests/local.at tests/regression.at :
> Adapted testsuite for the new category (-Wprecedence instead of -Wother for
> these warnings)
Imperative (likewise for the title). End sentences with "."
> ---
> NEWS | 28 ++++--
> doc/bison.texi | 19 ++++
> src/complain.c | 1 +
> src/complain.h | 4 +-
> src/getargs.c | 3 +
> src/symtab.c | 4 +-
> tests/conflicts.at | 68 +++++++-------
> tests/existing.at | 258 +++++++++++++++++++++++++--------------------------
> tests/local.at | 2 +-
> tests/regression.at | 10 +-
> 10 files changed, 218 insertions(+), 179 deletions(-)
>
> diff --git a/NEWS b/NEWS
> index 62f834b..24228a2 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -198,13 +198,6 @@ GNU Bison NEWS
> bar.y: error: shift/reduce conflicts: 1 found, 0 expected
> bar.y: error: reduce/reduce conflicts: 2 found, 0 expected
>
> -*** Useless precedence
> -
> - Bison now warns about symbols with a declared precedence but no declared
> - associativity (i.e. declared with %precedence), and whose precedence is
> - never used. In that case, the symbol can be safely declared with %token
> - instead, without modifying the parsing tables.
> -
> ** Additional yylex/yyparse arguments
>
> The new directive %param declares additional arguments to both yylex and
> @@ -303,6 +296,27 @@ GNU Bison NEWS
> when declaring associativity at the same time, with %left (or %right,
> %precedence, %nonassoc), B was inferior to A.
>
> +** Useless precedence and associativity
> +
> +*** Useless precedence
> +
> + Bison now warns about symbols with a declared precedence but no declared
> + associativity (i.e. declared with %precedence), and whose precedence is
> + never used. In that case, the symbol can be safely declared with %token
> + instead, without modifying the parsing tables.
> +
> +*** Useless associativity
> +
> + Bison now warns about symbols with a declared associativity that is never
> + used to resolve conflicts. In that case, the symbol can be safely declared
> + with %precedence instead.
I'd prefer "In that case using %precedence is sufficient".
> Solving these warnings may raise useless precedence
> + warnings, as the symbols no longer have associativity.
> +
> +*** Precedence warning category
> +
> + A new category of warning, precedence (-Wprecedence) has been introduced,
> and
> + is used for the useless precedence and associativity warnings.
I would also put the three items in the exact inverse order.
And please, show (short!) examples for both cases, including
the warning message.
> +
> * Noteworthy changes in release 2.7 (2012-12-12) [stable]
>
> ** Bug fixes
> diff --git a/doc/bison.texi b/doc/bison.texi
> index d2d3da3..340fadd 100644
> --- a/doc/bison.texi
> +++ b/doc/bison.texi
> @@ -9716,6 +9716,25 @@ no effect on the conflict report.
> Deprecated constructs whose support will be removed in future versions of
> Bison.
>
> address@hidden precedence
> +Useless precedence and associativity. Bison detects whether defined
> precedence
> +and associativity are uselfull, and warn if not. For example, in the grammar
useful. warns.
> +below, warn about useless associativity for '=' :
"bison warns about…"
No space before ":".
> +
> address@hidden
> +%token VAR NUM
> +%nonassoc '='
> +%%
> +assign: VAR '=' NUM;
> address@hidden example
Don't use %token, directly use "var" and "num".
> +
> +In this case, two '='
@samp{=}
> in a row
Well, it's not exactly in a row: you don't mean "= =".
So provide an example, say @samp{a = b = c}.
> will be detected as a syntax error even without
> +%nonassoc (there are no rule allowing that case), so the associativity is
@code{%nonassoc}
> +%useless,
%useless :)
> and can be replaced by %precedence. Bison then warns about useless
@code{%precedence}. And so on.
Please, submit an updated patch.
> +%precedence, because '=' can be safely declared as a %token (there are no
> +%conflicts involving '=' solved with precedence comparison). This warning is
> +%disabled by default.
> +
> @item other
> All warnings not categorized above. These warnings are enabled by default.
- [PATCH] {master} New warning category precedence, Valentin Tolmer, 2013/01/30
- [PATCH] warnings: introduced -Wprecedence, Valentin Tolmer, 2013/01/30
- Re: [PATCH] warnings: introduced -Wprecedence,
Akim Demaille <=
- Re: [PATCH] warnings: introduced -Wprecedence, Valentin Tolmer, 2013/01/30
- Re: [PATCH] warnings: introduced -Wprecedence, Akim Demaille, 2013/01/30
- Re: [PATCH] warnings: introduced -Wprecedence, Valentin Tolmer, 2013/01/30
- Re: [PATCH] warnings: introduced -Wprecedence, Valentin Tolmer, 2013/01/30
- Re: [PATCH] warnings: introduced -Wprecedence, Akim Demaille, 2013/01/30