mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 04:13:03 +00:00
Convert multiple variable definition warnings to complaints.
* NEWS (2.5): Add a new entry for that change.
* doc/bison.texinfo (Decl Summary): Update %define entry.
(Bison Options): Update -D/--define/-F/--force-define entry.
* src/muscle-tab.c (muscle_percent_define_insert): Implement.
* src/muscle-tab.h (muscle_percent_define_insert): Update
comments.
* tests/input.at (`%define errors'): Update.
(`%define, --define, --force-define'): Update.
(cherry picked from commit e3a33f7c23)
This commit is contained in:
12
ChangeLog
12
ChangeLog
@@ -1,3 +1,15 @@
|
||||
2009-05-22 Joel E. Denny <jdenny@ces.clemson.edu>
|
||||
|
||||
Convert multiple variable definition warnings to complaints.
|
||||
* NEWS (2.5): Add a new entry for that change.
|
||||
* doc/bison.texinfo (Decl Summary): Update %define entry.
|
||||
(Bison Options): Update -D/--define/-F/--force-define entry.
|
||||
* src/muscle-tab.c (muscle_percent_define_insert): Implement.
|
||||
* src/muscle-tab.h (muscle_percent_define_insert): Update
|
||||
comments.
|
||||
* tests/input.at (`%define errors'): Update.
|
||||
(`%define, --define, --force-define'): Update.
|
||||
|
||||
2009-05-22 Joel E. Denny <jdenny@ces.clemson.edu>
|
||||
|
||||
-F/--force-define and relative %define/-D/--define priorities.
|
||||
|
||||
2
NEWS
2
NEWS
@@ -57,6 +57,8 @@ Bison News
|
||||
These features are experimental. More user feedback will help to
|
||||
stabilize them.
|
||||
|
||||
** Multiple %define's for any variable is now an error not a warning.
|
||||
|
||||
** %define can now be invoked via the command line.
|
||||
|
||||
Each of these command-line options
|
||||
|
||||
@@ -4845,8 +4845,8 @@ The possible choices for @var{variable}, as well as their meanings, depend on
|
||||
the selected target language and/or the parser skeleton (@pxref{Decl
|
||||
Summary,,%language}, @pxref{Decl Summary,,%skeleton}).
|
||||
|
||||
Bison will warn if a @var{variable} is defined by @code{%define}
|
||||
multiple times, but @ref{Bison Options,,-D @var{name}[=@var{value}]}.
|
||||
It is an error if a @var{variable} is defined by @code{%define} multiple
|
||||
times, but @ref{Bison Options,,-D @var{name}[=@var{value}]}.
|
||||
|
||||
Omitting @code{"@var{value}"} is always equivalent to specifying it as
|
||||
@code{""}.
|
||||
@@ -8149,16 +8149,19 @@ definitions for the same @var{name} as follows:
|
||||
|
||||
@itemize
|
||||
@item
|
||||
Bison processes all command-line definitions in order and then processes
|
||||
all @code{%define} definitions in order.
|
||||
Bison quietly ignores all command-line definitions for @var{name} except
|
||||
the last.
|
||||
@item
|
||||
Later definitions override earlier definitions except that Bison quietly
|
||||
ignores all @code{%define} definitions if the last command-line
|
||||
definition is specified by @code{-F} or @code{--force-define}.
|
||||
If that command-line definition is specified by a @code{-D} or
|
||||
@code{--define}, Bison reports an error for any @code{%define}
|
||||
definition for @var{name}.
|
||||
@item
|
||||
Bison never warns when a command-line definition overrides another
|
||||
definition, but Bison always warns when a @code{%define} definition
|
||||
overrides a command-line or @code{%define} definition.
|
||||
If that command-line definition is specified by a @code{-F} or
|
||||
@code{--force-define} instead, Bison quietly ignores all @code{%define}
|
||||
definitions for @var{name}.
|
||||
@item
|
||||
Otherwise, Bison reports an error if there are multiple @code{%define}
|
||||
definitions for @var{name}.
|
||||
@end itemize
|
||||
|
||||
You should avoid using @code{-F} and @code{--force-define} in your
|
||||
|
||||
@@ -436,9 +436,9 @@ muscle_percent_define_insert (char const *variable, location variable_loc,
|
||||
free (variable_tr);
|
||||
return;
|
||||
}
|
||||
warn_at (variable_loc, _("%s `%s' redefined"),
|
||||
"%define variable", variable);
|
||||
warn_at (muscle_percent_define_get_loc (variable),
|
||||
complain_at (variable_loc, _("%s `%s' redefined"),
|
||||
"%define variable", variable);
|
||||
complain_at (muscle_percent_define_get_loc (variable),
|
||||
_("previous definition"));
|
||||
}
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ typedef enum {
|
||||
/* Define the muscles for %define variable VARIABLE with VALUE specified
|
||||
at VARIABLE_LOC in the manner HOW unless it was specified in the
|
||||
grammar file while the previous definition for VARIABLE was specified
|
||||
with -F/--force-define. Warn if a previous definition is being
|
||||
with -F/--force-define. Complain if a previous definition is being
|
||||
overridden and the new definition is specified in the grammar file.
|
||||
(These rules support the documented behavior as long as command-line
|
||||
definitions are processed before grammar file definitions.) Record
|
||||
|
||||
@@ -888,7 +888,7 @@ AT_CLEANUP
|
||||
|
||||
AT_SETUP([%define errors])
|
||||
|
||||
AT_DATA([input.y],
|
||||
AT_DATA([input-redefined.y],
|
||||
[[%define var "value1"
|
||||
%define var "value1"
|
||||
%define var "value2"
|
||||
@@ -898,16 +898,21 @@ AT_DATA([input.y],
|
||||
start: ;
|
||||
]])
|
||||
|
||||
AT_BISON_CHECK([[input.y]], [0], [],
|
||||
[[input.y:2.9-11: warning: %define variable `var' redefined
|
||||
input.y:1.9-11: warning: previous definition
|
||||
input.y:3.10-12: warning: %define variable `var' redefined
|
||||
input.y:2.9-11: warning: previous definition
|
||||
input.y:1.9-11: warning: %define variable `var' is not used
|
||||
input.y:2.9-11: warning: %define variable `var' is not used
|
||||
input.y:3.10-12: warning: %define variable `var' is not used
|
||||
input.y:4.9-16: warning: %define variable `special1' is not used
|
||||
input.y:5.9-16: warning: %define variable `special2' is not used
|
||||
AT_BISON_CHECK([[input-redefined.y]], [[1]], [],
|
||||
[[input-redefined.y:2.9-11: %define variable `var' redefined
|
||||
input-redefined.y:1.9-11: previous definition
|
||||
input-redefined.y:3.10-12: %define variable `var' redefined
|
||||
input-redefined.y:2.9-11: previous definition
|
||||
]])
|
||||
|
||||
AT_DATA([input-unused.y],
|
||||
[[%define var "value"
|
||||
%%
|
||||
start: ;
|
||||
]])
|
||||
|
||||
AT_BISON_CHECK([[input-unused.y]], [[0]], [],
|
||||
[[input-unused.y:1.9-11: warning: %define variable `var' is not used
|
||||
]])
|
||||
|
||||
AT_CLEANUP
|
||||
@@ -924,40 +929,45 @@ AT_DATA([skel.c],
|
||||
@output(b4_parser_file_name@)@
|
||||
[var-dd: ]b4_percent_define_get([[var-dd]])[
|
||||
var-ff: ]b4_percent_define_get([[var-ff]])[
|
||||
var-dg: ]b4_percent_define_get([[var-dg]])[
|
||||
var-dfg: ]b4_percent_define_get([[var-dfg]])[
|
||||
var-fd: ]b4_percent_define_get([[var-fd]])
|
||||
m4@&t@_divert_pop(0)
|
||||
]])
|
||||
|
||||
AT_DATA([input.y],
|
||||
[[%define var-dg "gram"
|
||||
%define var-dfg "gram"
|
||||
[[%define var-dfg "gram"
|
||||
%%
|
||||
start: ;
|
||||
]])
|
||||
|
||||
AT_BISON_CHECK([[-Dvar-dd=cmd-d1 -Dvar-dd=cmd-d2 \
|
||||
-Fvar-ff=cmd-f1 -Fvar-ff=cmd-f2 \
|
||||
-Dvar-dg=cmd-d \
|
||||
-Dvar-dfg=cmd-d -Fvar-dfg=cmd-f \
|
||||
-Fvar-fd=cmd-f -Dvar-fd=cmd-d \
|
||||
-Dunused-d -Funused-f \
|
||||
--skeleton ./skel.c input.y]], [0], [],
|
||||
[[input.y:1.9-14: warning: %define variable `var-dg' redefined
|
||||
<command line>:6: warning: previous definition
|
||||
<command line>:11: warning: %define variable `unused-d' is not used
|
||||
<command line>:12: warning: %define variable `unused-f' is not used
|
||||
--skeleton ./skel.c input.y]], [[0]], [],
|
||||
[[<command line>:10: warning: %define variable `unused-d' is not used
|
||||
<command line>:11: warning: %define variable `unused-f' is not used
|
||||
]])
|
||||
|
||||
AT_CHECK([[cat input.tab.c]], [[0]],
|
||||
[[var-dd: cmd-d2
|
||||
var-ff: cmd-f2
|
||||
var-dg: gram
|
||||
var-dfg: cmd-f
|
||||
var-fd: cmd-d
|
||||
]])
|
||||
|
||||
AT_DATA([input-dg.y],
|
||||
[[%define var "gram"
|
||||
%%
|
||||
start: ;
|
||||
]])
|
||||
|
||||
AT_BISON_CHECK([[-Dvar=cmd-d input-dg.y]], [[1]], [],
|
||||
[[input-dg.y:1.9-11: %define variable `var' redefined
|
||||
<command line>:2: previous definition
|
||||
]])
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
## --------------------------- ##
|
||||
|
||||
Reference in New Issue
Block a user