mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-19 17:23:02 +00:00
Warn about output files that are generated by the skeletons and that
conflict with other output files. * data/glr.c: Don't generate the header file here when glr.cc does. * src/files.c (file_names, file_names_count): New static globals. (compute_output_file_names): Invoke output_file_name_check for files not generated by the skeletons and remove existing checks. (output_file_name_check): New function that warns about conflicting output file names. (output_file_names_free): Free file_names. * src/files.h (output_file_name_check): Declare. * src/scan-skel.l: Invoke output_file_name_check for files generated by the skeletons. * tests/output.at (AT_CHECK_CONFLICTING_OUTPUT): New. (Conflicting output files): New tests.
This commit is contained in:
17
ChangeLog
17
ChangeLog
@@ -1,3 +1,20 @@
|
|||||||
|
2006-12-09 Joel E. Denny <jdenny@ces.clemson.edu>
|
||||||
|
|
||||||
|
Warn about output files that are generated by the skeletons and that
|
||||||
|
conflict with other output files.
|
||||||
|
* data/glr.c: Don't generate the header file here when glr.cc does.
|
||||||
|
* src/files.c (file_names, file_names_count): New static globals.
|
||||||
|
(compute_output_file_names): Invoke output_file_name_check for files
|
||||||
|
not generated by the skeletons and remove existing checks.
|
||||||
|
(output_file_name_check): New function that warns about conflicting
|
||||||
|
output file names.
|
||||||
|
(output_file_names_free): Free file_names.
|
||||||
|
* src/files.h (output_file_name_check): Declare.
|
||||||
|
* src/scan-skel.l: Invoke output_file_name_check for files generated by
|
||||||
|
the skeletons.
|
||||||
|
* tests/output.at (AT_CHECK_CONFLICTING_OUTPUT): New.
|
||||||
|
(Conflicting output files): New tests.
|
||||||
|
|
||||||
2006-12-09 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
|
2006-12-09 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
|
||||||
|
|
||||||
* doc/bison.texinfo: Fix a couple of typos.
|
* doc/bison.texinfo: Fix a couple of typos.
|
||||||
|
|||||||
@@ -2624,7 +2624,11 @@ yypdumpstack (yyGLRStack* yystackp)
|
|||||||
]
|
]
|
||||||
|
|
||||||
b4_epilogue
|
b4_epilogue
|
||||||
b4_defines_if(
|
dnl
|
||||||
|
dnl glr.cc produces its own header.
|
||||||
|
dnl
|
||||||
|
m4_if(b4_skeleton, ["glr.c"],
|
||||||
|
[b4_defines_if(
|
||||||
[@output @output_header_name@
|
[@output @output_header_name@
|
||||||
b4_copyright([Skeleton interface for Bison GLR parsers in C],
|
b4_copyright([Skeleton interface for Bison GLR parsers in C],
|
||||||
[2002, 2003, 2004, 2005, 2006])
|
[2002, 2003, 2004, 2005, 2006])
|
||||||
@@ -2636,4 +2640,4 @@ extern YYSTYPE b4_prefix[]lval;
|
|||||||
b4_locations_if([b4_pure_if([],
|
b4_locations_if([b4_pure_if([],
|
||||||
[extern YYLTYPE b4_prefix[]lloc;])
|
[extern YYLTYPE b4_prefix[]lloc;])
|
||||||
])
|
])
|
||||||
])
|
])])
|
||||||
|
|||||||
40
src/files.c
40
src/files.c
@@ -53,6 +53,10 @@ char *spec_graph_file = NULL; /* for -g. */
|
|||||||
char *spec_defines_file = NULL; /* for --defines. */
|
char *spec_defines_file = NULL; /* for --defines. */
|
||||||
char *parser_file_name;
|
char *parser_file_name;
|
||||||
|
|
||||||
|
/* All computed output file names. */
|
||||||
|
static char **file_names = NULL;
|
||||||
|
static int file_names_count = 0;
|
||||||
|
|
||||||
uniqstr grammar_file = NULL;
|
uniqstr grammar_file = NULL;
|
||||||
uniqstr current_file = NULL;
|
uniqstr current_file = NULL;
|
||||||
|
|
||||||
@@ -292,11 +296,6 @@ compute_file_name_parts (void)
|
|||||||
void
|
void
|
||||||
compute_output_file_names (void)
|
compute_output_file_names (void)
|
||||||
{
|
{
|
||||||
char const *name[4];
|
|
||||||
int i;
|
|
||||||
int j;
|
|
||||||
int names = 0;
|
|
||||||
|
|
||||||
compute_file_name_parts ();
|
compute_file_name_parts ();
|
||||||
|
|
||||||
/* If not yet done. */
|
/* If not yet done. */
|
||||||
@@ -305,7 +304,7 @@ compute_output_file_names (void)
|
|||||||
if (!header_extension)
|
if (!header_extension)
|
||||||
header_extension = xstrdup (".h");
|
header_extension = xstrdup (".h");
|
||||||
|
|
||||||
name[names++] = parser_file_name =
|
parser_file_name =
|
||||||
(spec_outfile
|
(spec_outfile
|
||||||
? xstrdup (spec_outfile)
|
? xstrdup (spec_outfile)
|
||||||
: concat2 (all_but_ext, src_extension));
|
: concat2 (all_but_ext, src_extension));
|
||||||
@@ -314,33 +313,40 @@ compute_output_file_names (void)
|
|||||||
{
|
{
|
||||||
if (! spec_defines_file)
|
if (! spec_defines_file)
|
||||||
spec_defines_file = concat2 (all_but_ext, header_extension);
|
spec_defines_file = concat2 (all_but_ext, header_extension);
|
||||||
name[names++] = spec_defines_file;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (graph_flag)
|
if (graph_flag)
|
||||||
{
|
{
|
||||||
if (! spec_graph_file)
|
if (! spec_graph_file)
|
||||||
spec_graph_file = concat2 (all_but_tab_ext, ".dot");
|
spec_graph_file = concat2 (all_but_tab_ext, ".dot");
|
||||||
name[names++] = spec_graph_file;
|
output_file_name_check (spec_graph_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (report_flag)
|
if (report_flag)
|
||||||
{
|
{
|
||||||
spec_verbose_file = concat2 (all_but_tab_ext, OUTPUT_EXT);
|
spec_verbose_file = concat2 (all_but_tab_ext, OUTPUT_EXT);
|
||||||
name[names++] = spec_verbose_file;
|
output_file_name_check (spec_verbose_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j < names; j++)
|
|
||||||
for (i = 0; i < j; i++)
|
|
||||||
if (strcmp (name[i], name[j]) == 0)
|
|
||||||
warn (_("conflicting outputs to file %s"), quote (name[i]));
|
|
||||||
|
|
||||||
free (all_but_ext);
|
free (all_but_ext);
|
||||||
free (all_but_tab_ext);
|
free (all_but_tab_ext);
|
||||||
free (src_extension);
|
free (src_extension);
|
||||||
free (header_extension);
|
free (header_extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
output_file_name_check (char const *file_name)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < file_names_count; i++)
|
||||||
|
if (0 == strcmp (file_names[i], file_name))
|
||||||
|
warn (_("conflicting outputs to file %s"), quote (file_name));
|
||||||
|
}
|
||||||
|
file_names = xnrealloc (file_names, ++file_names_count, sizeof *file_names);
|
||||||
|
file_names[file_names_count-1] = xstrdup (file_name);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
output_file_names_free (void)
|
output_file_names_free (void)
|
||||||
{
|
{
|
||||||
@@ -349,4 +355,10 @@ output_file_names_free (void)
|
|||||||
free (spec_defines_file);
|
free (spec_defines_file);
|
||||||
free (parser_file_name);
|
free (parser_file_name);
|
||||||
free (dir_prefix);
|
free (dir_prefix);
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < file_names_count; i++)
|
||||||
|
free (file_names[i]);
|
||||||
|
}
|
||||||
|
free (file_names);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ extern uniqstr current_file;
|
|||||||
|
|
||||||
void compute_output_file_names (void);
|
void compute_output_file_names (void);
|
||||||
void output_file_names_free (void);
|
void output_file_names_free (void);
|
||||||
|
void output_file_name_check (char const *file_name);
|
||||||
|
|
||||||
FILE *xfopen (const char *name, const char *mode);
|
FILE *xfopen (const char *name, const char *mode);
|
||||||
void xfclose (FILE *ptr);
|
void xfclose (FILE *ptr);
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ int skel_lex (void);
|
|||||||
xfclose (yyout);
|
xfclose (yyout);
|
||||||
}
|
}
|
||||||
outname = xstrdup (file_name);
|
outname = xstrdup (file_name);
|
||||||
|
output_file_name_check (file_name);
|
||||||
yyout = xfopen (outname, "w");
|
yyout = xfopen (outname, "w");
|
||||||
lineno = 1;
|
lineno = 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,3 +116,36 @@ AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose],
|
|||||||
[-o subdir/foo.cc],
|
[-o subdir/foo.cc],
|
||||||
[subdir/foo.cc subdir/foo.hh subdir/foo.output subdir/location.hh subdir/stack.hh subdir/position.hh],
|
[subdir/foo.cc subdir/foo.hh subdir/foo.output subdir/location.hh subdir/stack.hh subdir/position.hh],
|
||||||
[], [AT_CHECK_NO_SUBDIR_PART([subdir/foo])])
|
[], [AT_CHECK_NO_SUBDIR_PART([subdir/foo])])
|
||||||
|
|
||||||
|
|
||||||
|
# AT_CHECK_CONFLICTING_OUTPUT(INPUT-FILE, DIRECTIVES, FLAGS, STDERR)
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
m4_define([AT_CHECK_CONFLICTING_OUTPUT],
|
||||||
|
[AT_SETUP([Conflicting output files: $2 $3])
|
||||||
|
case "$1" in
|
||||||
|
*/*) mkdir `echo "$1" | sed 's,/.*,,'`;;
|
||||||
|
esac
|
||||||
|
AT_DATA([$1],
|
||||||
|
[[$2
|
||||||
|
%%
|
||||||
|
foo: {};
|
||||||
|
]])
|
||||||
|
|
||||||
|
AT_CHECK([bison $3 $1], 0, [], [$4])
|
||||||
|
AT_CLEANUP
|
||||||
|
])
|
||||||
|
|
||||||
|
AT_CHECK_CONFLICTING_OUTPUT([foo.y],
|
||||||
|
[], [--graph="foo.tab.c"],
|
||||||
|
[foo.y: warning: conflicting outputs to file `foo.tab.c'
|
||||||
|
])
|
||||||
|
|
||||||
|
AT_CHECK_CONFLICTING_OUTPUT([foo.y],
|
||||||
|
[%defines "foo.output"], [-v],
|
||||||
|
[foo.y: warning: conflicting outputs to file `foo.output'
|
||||||
|
])
|
||||||
|
|
||||||
|
AT_CHECK_CONFLICTING_OUTPUT([foo.y],
|
||||||
|
[%skeleton "lalr1.cc" %defines], [--graph="location.hh"],
|
||||||
|
[foo.y: warning: conflicting outputs to file `location.hh'
|
||||||
|
])
|
||||||
|
|||||||
Reference in New Issue
Block a user