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 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>
* doc/bison.texinfo: Fix a couple of typos.
]
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@
b4_copyright([Skeleton interface for Bison GLR parsers in C],
[2002, 2003, 2004, 2005, 2006])
b4_locations_if([b4_pure_if([],
[extern YYLTYPE b4_prefix[]lloc;])
])
-])
+])])
char *spec_defines_file = NULL; /* for --defines. */
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 current_file = NULL;
void
compute_output_file_names (void)
{
- char const *name[4];
- int i;
- int j;
- int names = 0;
-
compute_file_name_parts ();
/* If not yet done. */
if (!header_extension)
header_extension = xstrdup (".h");
- name[names++] = parser_file_name =
+ parser_file_name =
(spec_outfile
? xstrdup (spec_outfile)
: concat2 (all_but_ext, src_extension));
{
if (! spec_defines_file)
spec_defines_file = concat2 (all_but_ext, header_extension);
- name[names++] = spec_defines_file;
}
if (graph_flag)
{
if (! spec_graph_file)
spec_graph_file = concat2 (all_but_tab_ext, ".dot");
- name[names++] = spec_graph_file;
+ output_file_name_check (spec_graph_file);
}
if (report_flag)
{
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_tab_ext);
free (src_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
output_file_names_free (void)
{
free (spec_defines_file);
free (parser_file_name);
free (dir_prefix);
+ {
+ int i;
+ for (i = 0; i < file_names_count; i++)
+ free (file_names[i]);
+ }
+ free (file_names);
}
void compute_output_file_names (void);
void output_file_names_free (void);
+void output_file_name_check (char const *file_name);
FILE *xfopen (const char *name, const char *mode);
void xfclose (FILE *ptr);
xfclose (yyout);
}
outname = xstrdup (file_name);
+ output_file_name_check (file_name);
yyout = xfopen (outname, "w");
lineno = 1;
}
[-o subdir/foo.cc],
[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_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'
+])