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>
+
+ * 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
2002-03-04 Akim Demaille <akim@epita.fr>
* src/reader.c (readgram): A missing `;' is a warning, not an
Changes in version 1.33b:
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
* 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
#include "system.h"
#include "getargs.h"
#include "system.h"
#include "getargs.h"
#include "files.h"
#include "gram.h"
#include "error.h"
#include "files.h"
#include "gram.h"
#include "error.h"
/* Computes the extensions from the grammar file name. */
filename_split (infile, &base, &tab, &ext);
/* Computes the extensions from the grammar file name. */
filename_split (infile, &base, &tab, &ext);
if (ext && !yacc_flag)
compute_exts_from_gf (ext);
}
if (ext && !yacc_flag)
compute_exts_from_gf (ext);
}
if (!spec_defines_file)
spec_defines_file = stringappend (full_base_name, header_extension);
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");
/* It the graph filename if not given, we create it. */
if (!spec_graph_file)
spec_graph_file = stringappend (short_base_name, ".vcg");
/* Output the generated parsing program for bison,
/* 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.
This file is part of Bison, the GNU Compiler Compiler.
-AT_CHECK([bison $3 $1], 0)
AT_CHECK([ls $4], [], [ignore])
AT_CLEANUP
])
AT_CHECK([ls $4], [], [ignore])
AT_CLEANUP
])
AT_CHECK_OUTPUT([foo.yy], [],
[-o foo.c++ --graph=foo.gph],
[foo.c++ foo.gph])
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