Commit 3d67ba1e by Geoffrey Keating Committed by Geoffrey Keating

cppfiles.c (pch_open_file): New parameter 'invalid_pch', set it.

2003-11-07  Geoffrey Keating  <geoffk@apple.com>

	* cppfiles.c (pch_open_file): New parameter 'invalid_pch', set it.
	(find_file_in_dir): Likewise.
	(_cpp_find_file): Print message if no header file is found
	but an invalid PCH file was.

2003-11-07  Geoffrey Keating  <geoffk@apple.com>

	* gcc.dg/pch/warn-1.c: Allow for more helpful error message.

From-SVN: r73353
parent 30321c39
2003-11-07 Geoffrey Keating <geoffk@apple.com>
* cppfiles.c (pch_open_file): New parameter 'invalid_pch', set it.
(find_file_in_dir): Likewise.
(_cpp_find_file): Print message if no header file is found
but an invalid PCH file was.
2003-11-08 Joseph S. Myers <jsm@polyomino.org.uk> 2003-11-08 Joseph S. Myers <jsm@polyomino.org.uk>
* c-typeck.c (pedantic_lvalue_warning): Deprecate compound * c-typeck.c (pedantic_lvalue_warning): Deprecate compound
......
...@@ -154,8 +154,10 @@ struct file_hash_entry ...@@ -154,8 +154,10 @@ struct file_hash_entry
}; };
static bool open_file (_cpp_file *file); static bool open_file (_cpp_file *file);
static bool pch_open_file (cpp_reader *pfile, _cpp_file *file); static bool pch_open_file (cpp_reader *pfile, _cpp_file *file,
static bool find_file_in_dir (cpp_reader *pfile, _cpp_file *file); bool *invalid_pch);
static bool find_file_in_dir (cpp_reader *pfile, _cpp_file *file,
bool *invalid_pch);
static bool read_file_guts (cpp_reader *pfile, _cpp_file *file); static bool read_file_guts (cpp_reader *pfile, _cpp_file *file);
static bool read_file (cpp_reader *pfile, _cpp_file *file); static bool read_file (cpp_reader *pfile, _cpp_file *file);
static bool should_stack_file (cpp_reader *, _cpp_file *file, bool import); static bool should_stack_file (cpp_reader *, _cpp_file *file, bool import);
...@@ -234,9 +236,13 @@ open_file (_cpp_file *file) ...@@ -234,9 +236,13 @@ open_file (_cpp_file *file)
return false; return false;
} }
/* Temporary PCH intercept of opening a file. */ /* Temporary PCH intercept of opening a file. Try to find a PCH file
based on FILE->name and FILE->dir, and test those found for
validity using PFILE->cb.valid_pch. Return true iff a valid file is
found. Set *INVALID_PCH if a PCH file is found but wasn't valid. */
static bool static bool
pch_open_file (cpp_reader *pfile, _cpp_file *file) pch_open_file (cpp_reader *pfile, _cpp_file *file, bool *invalid_pch)
{ {
static const char extension[] = ".gch"; static const char extension[] = ".gch";
const char *path = file->path; const char *path = file->path;
...@@ -285,6 +291,7 @@ pch_open_file (cpp_reader *pfile, _cpp_file *file) ...@@ -285,6 +291,7 @@ pch_open_file (cpp_reader *pfile, _cpp_file *file)
closedir (pchdir); closedir (pchdir);
} }
file->pch |= valid; file->pch |= valid;
*invalid_pch |= ! valid;
} }
if (valid) if (valid)
...@@ -297,9 +304,11 @@ pch_open_file (cpp_reader *pfile, _cpp_file *file) ...@@ -297,9 +304,11 @@ pch_open_file (cpp_reader *pfile, _cpp_file *file)
/* Try to open the path FILE->name appended to FILE->dir. This is /* Try to open the path FILE->name appended to FILE->dir. This is
where remap and PCH intercept the file lookup process. Return true where remap and PCH intercept the file lookup process. Return true
if the file was found, whether or not the open was successful. */ if the file was found, whether or not the open was successful.
Set *INVALID_PCH to true if a PCH file is found but wasn't valid. */
static bool static bool
find_file_in_dir (cpp_reader *pfile, _cpp_file *file) find_file_in_dir (cpp_reader *pfile, _cpp_file *file, bool *invalid_pch)
{ {
char *path; char *path;
...@@ -309,7 +318,7 @@ find_file_in_dir (cpp_reader *pfile, _cpp_file *file) ...@@ -309,7 +318,7 @@ find_file_in_dir (cpp_reader *pfile, _cpp_file *file)
path = append_file_to_dir (file->name, file->dir); path = append_file_to_dir (file->name, file->dir);
file->path = path; file->path = path;
if (pch_open_file (pfile, file)) if (pch_open_file (pfile, file, invalid_pch))
return true; return true;
if (open_file (file)) if (open_file (file))
...@@ -351,6 +360,7 @@ _cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir, bool f ...@@ -351,6 +360,7 @@ _cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir, bool f
{ {
struct file_hash_entry *entry, **hash_slot; struct file_hash_entry *entry, **hash_slot;
_cpp_file *file; _cpp_file *file;
bool invalid_pch = false;
/* Ensure we get no confusion between cached files and directories. */ /* Ensure we get no confusion between cached files and directories. */
if (start_dir == NULL) if (start_dir == NULL)
...@@ -369,13 +379,21 @@ _cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir, bool f ...@@ -369,13 +379,21 @@ _cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir, bool f
/* Try each path in the include chain. */ /* Try each path in the include chain. */
for (; !fake ;) for (; !fake ;)
{ {
if (find_file_in_dir (pfile, file)) if (find_file_in_dir (pfile, file, &invalid_pch))
break; break;
file->dir = file->dir->next; file->dir = file->dir->next;
if (file->dir == NULL) if (file->dir == NULL)
{ {
open_file_failed (pfile, file); open_file_failed (pfile, file);
if (invalid_pch)
{
cpp_error (pfile, CPP_DL_ERROR,
"One or more PCH files were found, but they were invalid.");
if (! cpp_get_options (pfile)->warn_invalid_pch)
cpp_error (pfile, CPP_DL_ERROR,
"Use -Winvalid-pch for more information.");
}
break; break;
} }
......
2003-11-07 Geoffrey Keating <geoffk@apple.com>
* gcc.dg/pch/warn-1.c: Allow for more helpful error message.
2003-11-08 Joseph S. Myers <jsm@polyomino.org.uk> 2003-11-08 Joseph S. Myers <jsm@polyomino.org.uk>
* gcc.dg/compound-lvalue-1.c: New test. * gcc.dg/compound-lvalue-1.c: New test.
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#define DEFINED_VALUE 3 #define DEFINED_VALUE 3
#include "warn-1.h"/* { dg-error "not used because `DEFINED_VALUE' is defined|No such file" } */ #include "warn-1.h"/* { dg-error "not used because `DEFINED_VALUE' is defined|No such file|they were invalid" } */
int main(void) int main(void)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment