summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkim Demaille <akim@lrde.epita.fr>2013-12-04 10:51:47 +0100
committerAkim Demaille <akim@lrde.epita.fr>2013-12-04 15:53:01 +0100
commit461983270c01b28cbb73424535408c8aded31573 (patch)
tree8915bd237e340f57e0582b77e33919273361bb29
parentea99d6e6a02a06bd63e788393fd42cde5cb1fa71 (diff)
downloadbison-461983270c01b28cbb73424535408c8aded31573.tar.gz
output: do not generate source files when late errors are caught
Reported by Alexandre Duret-Lutz as "second problem" in: http://lists.gnu.org/archive/html/bug-bison/2013-09/msg00015.html * bootstrap.conf: We need the "unlink" module. * src/files.h, src/files.c (unlink_generated_sources): New. * src/output.c: Use it. * tests/output.at: Check the case of late errors.
-rw-r--r--bootstrap.conf3
-rw-r--r--src/files.c10
-rw-r--r--src/files.h3
-rw-r--r--src/output.c5
-rw-r--r--tests/output.at10
5 files changed, 29 insertions, 2 deletions
diff --git a/bootstrap.conf b/bootstrap.conf
index c58470e2..186afa71 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -34,7 +34,8 @@ gnulib_modules='
readme-release
realloc-posix
spawn-pipe stdbool stpcpy strdup-posix strerror strtoul strverscmp
- unistd unistd-safer unlocked-io update-copyright unsetenv verify
+ unistd unistd-safer unlink unlocked-io
+ update-copyright unsetenv verify
warnings
xalloc
xalloc-die
diff --git a/src/files.c b/src/files.c
index 46868365..c50f774a 100644
--- a/src/files.c
+++ b/src/files.c
@@ -399,6 +399,16 @@ output_file_name_check (char **file_name, bool source)
}
void
+unlink_generated_sources (void)
+{
+ int i;
+ for (i = 0; i < generated_files_size; i++)
+ if (generated_files[i].is_source)
+ /* Ignore errors. The file might not even exist. */
+ unlink (generated_files[i].name);
+}
+
+void
output_file_names_free (void)
{
free (all_but_ext);
diff --git a/src/files.h b/src/files.h
index 94833f71..9b857190 100644
--- a/src/files.h
+++ b/src/files.h
@@ -70,6 +70,9 @@ void output_file_names_free (void);
*/
void output_file_name_check (char **file_name, bool source);
+/** Remove all the generated source files. */
+void unlink_generated_sources (void);
+
FILE *xfopen (const char *name, char const *mode);
void xfclose (FILE *ptr);
FILE *xfdopen (int fd, char const *mode);
diff --git a/src/output.c b/src/output.c
index 5eafb2e3..ab1bdea1 100644
--- a/src/output.c
+++ b/src/output.c
@@ -704,6 +704,11 @@ output (void)
/* Process the selected skeleton file. */
output_skeleton ();
+ /* If late errors were generated, destroy the generated source
+ files. */
+ if (complaint_status)
+ unlink_generated_sources ();
+
obstack_free (&format_obstack, NULL);
}
diff --git a/tests/output.at b/tests/output.at
index 66a3e5e9..be3078f8 100644
--- a/tests/output.at
+++ b/tests/output.at
@@ -43,7 +43,7 @@ done
]AT_DATA([$1],
[$2[
%%
-foo: {};
+foo: %empty {};
]])[
]AT_BISON_CHECK([$3 $1], [$5], [], [ignore])[
@@ -126,6 +126,14 @@ AT_CHECK_OUTPUT([foo.y], [%type <foo> useless],
[foo.dot foo.output foo.xml],
[1])
+# Do not generate code when there are late errors (even warnings as
+# errors).
+AT_CHECK_OUTPUT([foo.y], [%define useless],
+ [--defines --graph --xml --report=all -Wall -Werror],
+ [foo.dot foo.output foo.xml],
+ [1])
+
+
## ------------ ##
## C++ output. ##
## ------------ ##