summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkim Demaille <akim@lrde.epita.fr>2013-12-04 09:30:08 +0100
committerAkim Demaille <akim@lrde.epita.fr>2013-12-04 15:53:01 +0100
commit184b42c85be3d42c958173c550ea442baf96a8cd (patch)
treee61aac71e26d7b3f643cbf910ea9509a154a25cc
parentbe29c71dd8867cca0c1aab4cf3ef9d4d4d0cb7b6 (diff)
downloadbison-184b42c85be3d42c958173c550ea442baf96a8cd.tar.gz
output: do not generate source files when early errors are caught
Reported by Alexandre Duret-Lutz as "second problem" in: http://lists.gnu.org/archive/html/bug-bison/2013-09/msg00015.html One problem is that some errors are caught early, before the generation of output files, while others can only be detected afterwards (since, for instance, skeletons can raise errors themselves). This will be addressed in two steps: early errors do not generate source files at all, while later errors will remove the files that have already been generated. * src/scan-skel.l (yyout): Open to /dev/null when there are errors. * tests/output.at (AT_CHECK_FILES): Factored out of... (AT_CHECK_OUTPUT): this. Fuse the "SHELLIO" argument in the "FLAGS" one. Use $5 to denote the expected exit status. Add a test case for early errors.
-rw-r--r--NEWS10
-rw-r--r--src/scan-skel.l3
-rw-r--r--tests/output.at35
3 files changed, 35 insertions, 13 deletions
diff --git a/NEWS b/NEWS
index 1fa7d9b7..fdd92483 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,16 @@ GNU Bison NEWS
** Bug fixes
+*** Generated source files when errors are reported
+
+ When warnings are issued and -Werror is set, bison would still generate
+ the source files (*.c, *.h...). As a consequence, some runs of "make"
+ could fail the first time, but not the second (as the files were generated
+ anyway).
+
+ This is fixed: bison no longer generates this source files, but, of
+ course, still produces the various reports (*.output, *.xml, etc.).
+
*** %empty is used in reports
Empty right-hand sides are denoted by '%empty' in all the reports (text,
diff --git a/src/scan-skel.l b/src/scan-skel.l
index f13ee813..48c5e46a 100644
--- a/src/scan-skel.l
+++ b/src/scan-skel.l
@@ -245,7 +245,8 @@ at_output (int argc, char *argv[], char **out_namep, int *out_linenop)
}
*out_namep = xstrdup (argv[1]);
output_file_name_check (out_namep);
- yyout = xfopen (*out_namep, "w");
+ /* If there were errors, do not generate the output. */
+ yyout = xfopen (complaint_status ? "/dev/null" : *out_namep, "w");
*out_linenop = 1;
}
diff --git a/tests/output.at b/tests/output.at
index 266a5032..66a3e5e9 100644
--- a/tests/output.at
+++ b/tests/output.at
@@ -17,12 +17,23 @@
AT_BANNER([[Output file names.]])
+# AT_CHECK_FILES(EXPECTED-FILES, [IGNORED-FILES])
+# -----------------------------------------------
+# Check that the current directory contains FILE... (sorted).
+m4_define([AT_CHECK_FILES],
+[AT_CHECK([[find . -type f |
+ $PERL -ne '
+ s,\./,,; chomp;
+ push @file, $_ unless m{^($2|testsuite.log)$};
+ END { print join (" ", sort @file), "\n" }']],
+ [], [$1
+])])
-# AT_CHECK_OUTPUT(INPUT-FILE, [DIRECTIVES], [FLAGS], EXPECTED-FILES, [SHELLIO],
+# AT_CHECK_OUTPUT(INPUT-FILE, [DIRECTIVES], [FLAGS], EXPECTED-FILES, [STATUS],
# [ADDITIONAL-TESTS], [PRE-TESTS])
# -----------------------------------------------------------------------------
m4_define([AT_CHECK_OUTPUT],
-[AT_SETUP([[Output files: ]$2 $3 $5])[
+[AT_SETUP([[Output files: ]$2 $3])[
]$7[
for file in ]$1 $4[; do
case $file in
@@ -35,15 +46,9 @@ done
foo: {};
]])[
-]AT_BISON_CHECK([$3 $1 $5], 0)[
+]AT_BISON_CHECK([$3 $1], [$5], [], [ignore])[
# Ignore the files non-generated files
-]AT_CHECK([[find . -type f |
- $PERL -ne '
- s,\./,,; chomp;
- push @file, $_ unless m{^($1|testsuite.log)$};
- END { print join (" ", sort @file), "\n" }']],
- [], [$4
-])[
+]AT_CHECK_FILES([$4], [$1])[
]$6[
]AT_CLEANUP[
]])
@@ -54,9 +59,9 @@ AT_CHECK_OUTPUT([foo.y], [], [-dv],
# Some versions of Valgrind (at least valgrind-3.6.0.SVN-Debian) report
# "fgrep: write error: Bad file descriptor" when stdout is closed, so we
# skip this test group during maintainer-check-valgrind.
-AT_CHECK_OUTPUT([foo.y], [], [-dv],
+AT_CHECK_OUTPUT([foo.y], [], [-dv >&-],
[foo.output foo.tab.c foo.tab.h],
- [>&-], [],
+ [], [],
[AT_CHECK([[case "$PREBISON" in *valgrind*) exit 77;; esac]])])
AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.c],
@@ -114,6 +119,12 @@ AT_CHECK_OUTPUT([foo.yy], [],
[-o foo.c++ --graph=foo.gph],
[foo.c++ foo.gph])
+# Do not generate code when there are early errors (even warnings as
+# errors).
+AT_CHECK_OUTPUT([foo.y], [%type <foo> useless],
+ [--defines --graph --xml --report=all -Wall -Werror],
+ [foo.dot foo.output foo.xml],
+ [1])
## ------------ ##
## C++ output. ##