[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 16:05:18 +0100 |
> 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 category. -Wprecedence can now be used, but is disabled by default.
Start each new item on a new line. So basically, start each sentence
on its own line. Also, name what was introduced. For instance:
commit e8f7155d98c22579c871c293a0daa5f7752e7c2b
Author: Valentin Tolmer <address@hidden>
Date: Tue Jan 29 16:27:04 2013 +0100
grammar: record used associativity and print useless ones
Record which symbol associativity is used, and display useless ones.
* src/symtab.h, src/symtab.c (register_assoc, print_assoc_warnings): New
> Precedence category regroups the useless precedence and associativity
> warnings.
> * doc/bison.texi: Document the warnings and provide an example.
Specify the @node name that you upgraded. For instance:
* doc/bison.texi (mfcalc example): Fix associativity to remove
warning.
> * tests/conflicts.at tests/existing.at tests/local.at tests/regression.at:
Use ", " as separator.
> Adapt testsuite for the new category (-Wprecedence instead of -Wother for
Adapt (or adjust) _the_.
> these warnings).
> ---
> NEWS | 45 +++++++--
> doc/bison.texi | 18 ++++
> 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, 234 insertions(+), 179 deletions(-)
>
> diff --git a/NEWS b/NEWS
> index 62f834b..57d6d26 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,44 @@ 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
> +
> +*** Precedence warning category
> +
> + A new category of warning, precedence (-Wprecedence) has been introduced,
> and
> + is used for the useless precedence and associativity warnings.
> +
> +*** Useless associativity
> +
> + Bison now warns about symbols with a declared associativity that is never
> + used to resolve conflicts. In that case, using %precedence is sufficient.
> + Solving these warnings may raise useless precedence warnings, as the
> symbols
> + no longer have associativity. For example :
> +
> + %nonassoc '='
> + %%
> + e: VAR '=' NUM;
Use "var" and "num"
> +
> + will produce a
> +
> + warning: useless associativity for '=' [-Wprecedence]
> +
> +
> +*** Useless precedence
> +
> + Bison now warns about symbols with a declared precedence but no declared
> + associativity (i.e. declared with %precedence), and whose precedence is
"i.e., "
> + never used. In that case, the symbol can be safely declared with %token
> + instead, without modifying the parsing tables. For example :
No space before ":".
> +
> + %precedence '='
> + %%
> + e: VAR '=' NUM;
> +
> + will produce a
> +
> + warning: useless precedence for '=' [-Wprecedence]
> +
> * Noteworthy changes in release 2.7 (2012-12-12) [stable]
>
> ** Bug fixes
> diff --git a/doc/bison.texi b/doc/bison.texi
> index d2d3da3..39f2636 100644
> --- a/doc/bison.texi
> +++ b/doc/bison.texi
> @@ -9716,6 +9716,24 @@ 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 uselful, and warns if not. For example, in the grammar
useful.
> +below, Bison warns about useless associativity for @samp{=}:
> +
> address@hidden
> +%nonassoc '='
> +%%
> +assign: VAR '=' NUM;
Again.
> address@hidden example
> +
> +In this case, two @samp{=} in a row will be detected as a syntax error even
> without
Give an example of what you call "in a row".
> address@hidden (there are no rule allowing that case), so the associativity is
> +useless, and can be replaced by @code{%precedence}. Bison then warns about
> useless
> +precedence, because @samp{=} can be safely declared as a @code{%token}
> (there are no
> +conflicts involving @samp{=} solved with precedence comparison). This
> warning is
> +disabled by default.
All this is too wide. No more than 76 col please.
> +
> @item other
> All warnings not categorized above. These warnings are enabled by default.
>
> diff --git a/src/complain.c b/src/complain.c
> index d43e623..c6e03d5 100644
> --- a/src/complain.c
> +++ b/src/complain.c
> @@ -50,6 +50,7 @@ warnings_print_categories (warnings warn_flags)
> "conflicts-sr",
> "conflicts-rr",
> "deprecated",
> + "precedence",
> "other"
> };
>