Is CPP broken? (Re: Strange gcc error message)
Zack Weinberg
zack@codesourcery.com
Mon Oct 8 11:27:00 GMT 2001
> * cppfiles.c (open_file): Don't mark zero-length files
> never-reread here. Don't output diagnostics here either.
> (stack_include_file): Mark them never-reread here.
> (_cpp_read_file): Update.
The patch looks good, but we still get the "Errors detected..."
message for an unreadable test file.
$ echo 'int foo;' > test.c
$ chmod 0 test.c
$ ./cc1 -quiet test.c
cc1: test.c: Permission denied
Errors detected in input file (your bison.simple is out of date)
I think this will happen for any condition where cpp_start_read
returns an error: the constraint being enforced here is that whenever
yyparse returns 1, errorcount is nonzero. The appended patch is the
simplest way to deal with the problem.
It might be appropriate to change this bit of toplev.c
if (yyparse () != 0)
{
if (errorcount == 0)
fnotice (stderr, "Errors detected in input file (your bison.simple is out of date)\n");
to abort if errorcount is zero, rather than printing that rather
obscure message. It _is_ an internal error - errors have been
detected but not reported (as far as toplev.c knows).
zw
===================================================================
Index: c-lex.c
--- c-lex.c 2001/10/07 16:50:50 1.153
+++ c-lex.c 2001/10/08 18:23:29
@@ -38,6 +38,7 @@ Software Foundation, 59 Temple Place - S
#include "tm_p.h"
#include "splay-tree.h"
#include "debug.h"
+#include "diagnostic.h"
/* MULTIBYTE_CHARS support only works for native compilers.
??? Ideally what we want is to model widechar support after
@@ -161,7 +162,10 @@ int
yyparse()
{
if (! cpp_start_read (parse_in, cpp_filename))
- return 1; /* cpplib has emitted an error. */
+ {
+ errorcount++;
+ return 1; /* cpplib has emitted an error. */
+ }
return yyparse_1();
}
More information about the Gcc-bugs
mailing list