[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
warn about conflicting skeleton-generated files
From: |
Joel E. Denny |
Subject: |
warn about conflicting skeleton-generated files |
Date: |
Sat, 9 Dec 2006 19:16:21 -0500 (EST) |
Bison should warn about:
bison --skeleton="lalr1.cc" --graph="location.hh" foo.y
since lalr1.cc generates a location.hh. I committed the following to make
that happen.
Index: ChangeLog
===================================================================
RCS file: /sources/bison/bison/ChangeLog,v
retrieving revision 1.1616
diff -p -u -r1.1616 ChangeLog
--- ChangeLog 9 Dec 2006 18:52:01 -0000 1.1616
+++ ChangeLog 10 Dec 2006 00:12:09 -0000
@@ -1,3 +1,20 @@
+2006-12-09 Joel E. Denny <address@hidden>
+
+ 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 <address@hidden>
* doc/bison.texinfo: Fix a couple of typos.
Index: data/glr.c
===================================================================
RCS file: /sources/bison/bison/data/glr.c,v
retrieving revision 1.191
diff -p -u -r1.191 glr.c
--- data/glr.c 15 Oct 2006 12:37:06 -0000 1.191
+++ data/glr.c 10 Dec 2006 00:12:10 -0000
@@ -2624,7 +2624,11 @@ yypdumpstack (yyGLRStack* yystackp)
]
b4_epilogue
-b4_defines_if(
+dnl
+dnl glr.cc produces its own header.
+dnl
+m4_if(b4_skeleton, ["glr.c"],
+[b4_defines_if(
address@hidden @output_header_name@
b4_copyright([Skeleton interface for Bison GLR parsers in C],
[2002, 2003, 2004, 2005, 2006])
@@ -2636,4 +2640,4 @@ extern YYSTYPE b4_prefix[]lval;
b4_locations_if([b4_pure_if([],
[extern YYLTYPE b4_prefix[]lloc;])
])
-])
+])])
Index: src/files.c
===================================================================
RCS file: /sources/bison/bison/src/files.c,v
retrieving revision 1.99
diff -p -u -r1.99 files.c
--- src/files.c 9 Nov 2006 18:17:05 -0000 1.99
+++ src/files.c 10 Dec 2006 00:12:14 -0000
@@ -53,6 +53,10 @@ char *spec_graph_file = NULL; /* for
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;
@@ -292,11 +296,6 @@ compute_file_name_parts (void)
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. */
@@ -305,7 +304,7 @@ compute_output_file_names (void)
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));
@@ -314,27 +313,21 @@ compute_output_file_names (void)
{
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);
@@ -342,6 +335,19 @@ compute_output_file_names (void)
}
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_verbose_file);
@@ -349,4 +355,10 @@ 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);
}
Index: src/files.h
===================================================================
RCS file: /sources/bison/bison/src/files.h,v
retrieving revision 1.42
diff -p -u -r1.42 files.h
--- src/files.h 8 Nov 2006 20:28:57 -0000 1.42
+++ src/files.h 10 Dec 2006 00:12:14 -0000
@@ -64,6 +64,7 @@ extern uniqstr current_file;
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);
Index: src/scan-skel.l
===================================================================
RCS file: /sources/bison/bison/src/scan-skel.l,v
retrieving revision 1.42
diff -p -u -r1.42 scan-skel.l
--- src/scan-skel.l 10 Nov 2006 05:26:26 -0000 1.42
+++ src/scan-skel.l 10 Dec 2006 00:12:15 -0000
@@ -81,6 +81,7 @@ int skel_lex (void);
xfclose (yyout);
}
outname = xstrdup (file_name);
+ output_file_name_check (file_name);
yyout = xfopen (outname, "w");
lineno = 1;
}
Index: tests/output.at
===================================================================
RCS file: /sources/bison/bison/tests/output.at,v
retrieving revision 1.12
diff -p -u -r1.12 output.at
--- tests/output.at 2 Dec 2006 01:52:16 -0000 1.12
+++ tests/output.at 10 Dec 2006 00:12:15 -0000
@@ -116,3 +116,36 @@ AT_CHECK_OUTPUT([subdir/foo.yy], [%skele
[-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'
+])
- warn about conflicting skeleton-generated files,
Joel E. Denny <=
- Re: warn about conflicting skeleton-generated files, Hans Aberg, 2006/12/10
- Re: warn about conflicting skeleton-generated files, Joel E. Denny, 2006/12/12
- Re: warn about conflicting skeleton-generated files, Paul Eggert, 2006/12/13
- Re: warn about conflicting skeleton-generated files, Joel E. Denny, 2006/12/13
- Re: warn about conflicting skeleton-generated files, Hans Aberg, 2006/12/13
- Re: warn about conflicting skeleton-generated files, Paul Eggert, 2006/12/13
- Re: warn about conflicting skeleton-generated files, Joel E. Denny, 2006/12/13
- Re: warn about conflicting skeleton-generated files, Paul Eggert, 2006/12/13
- Re: warn about conflicting skeleton-generated files, Joel E. Denny, 2006/12/13
- Re: warn about conflicting skeleton-generated files, Paul Eggert, 2006/12/13