summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkim Demaille <akim@epita.fr>2002-03-04 18:06:42 +0000
committerAkim Demaille <akim@epita.fr>2002-03-04 18:06:42 +0000
commit4eeb7bc9a28b4ed306b49678048bc090628e2922 (patch)
tree331566dd980db9116222bfc5efa97454df700fbb
parent5d08b24fbaf0169e3641c944e53a29a48f8558c9 (diff)
downloadbison-4eeb7bc9a28b4ed306b49678048bc090628e2922.tar.gz
* tests/output.at (AT_CHECK_OUTPUT): Another test, making sure
bison fails when trying to output a parser and a header under the same name. * src/files.c (compute_output_file_names): Refuse when parser and header have the same name.
-rw-r--r--ChangeLog8
-rw-r--r--NEWS4
-rw-r--r--src/files.c17
-rw-r--r--src/output.c4
-rw-r--r--tests/output.at14
5 files changed, 43 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 0a75128a..f4a5ec07 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2002-03-04 Akim Demaille <akim@epita.fr>
+ * tests/output.at (AT_CHECK_OUTPUT): Another test, making sure
+ bison fails when trying to output a parser and a header under the
+ same name.
+ * src/files.c (compute_output_file_names): Refuse when parser and
+ header have the same name.
+
+2002-03-04 Akim Demaille <akim@epita.fr>
+
* src/reader.c (readgram): A missing `;' is a warning, not an
error!
diff --git a/NEWS b/NEWS
index a30792b1..446dee35 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,10 @@ Bison News
Changes in version 1.33b:
+* File name clashes are detected
+ $ bison foo.y -d -o foo.x
+ fatal error: header and parser would be both named `foo.x'
+
* A missing `;' ending a rule triggers a warning
In accordance with POSIX, and in agreement with other
Yacc implementations, Bison will mandate this semicolon in a near
diff --git a/src/files.c b/src/files.c
index 83c863ff..a7061d32 100644
--- a/src/files.c
+++ b/src/files.c
@@ -22,6 +22,7 @@
#include "system.h"
#include "getargs.h"
+#include "quote.h"
#include "files.h"
#include "gram.h"
#include "error.h"
@@ -419,7 +420,7 @@ compute_base_names (void)
/* Computes the extensions from the grammar file name. */
filename_split (infile, &base, &tab, &ext);
-
+
if (ext && !yacc_flag)
compute_exts_from_gf (ext);
}
@@ -445,6 +446,20 @@ compute_output_file_names (void)
if (!spec_defines_file)
spec_defines_file = stringappend (full_base_name, header_extension);
+ if (defines_flag)
+ {
+ /* This is really Q&D, but I don't want to spend time on issues
+ which will be different with 1.50. */
+ const char *parser_filename = NULL;
+ if (spec_outfile)
+ parser_filename = spec_outfile;
+ else
+ parser_filename = stringappend (full_base_name, src_extension);
+ if (!strcmp (spec_defines_file, parser_filename))
+ fatal ("header and parser would be both named %s",
+ quote (parser_filename));
+ }
+
/* It the graph filename if not given, we create it. */
if (!spec_graph_file)
spec_graph_file = stringappend (short_base_name, ".vcg");
diff --git a/src/output.c b/src/output.c
index 43738316..72289e87 100644
--- a/src/output.c
+++ b/src/output.c
@@ -1,7 +1,7 @@
/* Output the generated parsing program for bison,
- Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001 Free Software
- Foundation, Inc.
+ Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001, 2002
+ Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
diff --git a/tests/output.at b/tests/output.at
index 147e8b28..a1ac9947 100644
--- a/tests/output.at
+++ b/tests/output.at
@@ -29,7 +29,7 @@ AT_DATA([$1],
foo: {};
]])
-AT_CHECK([bison $3 $1], 0)
+AT_CHECK([bison $3 $1])
AT_CHECK([ls $4], [], [ignore])
AT_CLEANUP
])
@@ -81,3 +81,15 @@ AT_CHECK_OUTPUT([foo.yy], [],
AT_CHECK_OUTPUT([foo.yy], [],
[-o foo.c++ --graph=foo.gph],
[foo.c++ foo.gph])
+
+# Be sure to reject cases where the parser and the header would have
+# the same name.
+AT_SETUP([Clashing Output Files.])
+AT_DATA([foo.y],
+[[%% foo: {};
+]])
+
+AT_CHECK([bison -do foo.x foo.y], [1], [],
+ [foo.y:2: fatal error: header and parser would be both named `foo.x'
+])
+AT_CLEANUP