summaryrefslogtreecommitdiff
path: root/libcpp/files.c
diff options
context:
space:
mode:
Diffstat (limited to 'libcpp/files.c')
-rw-r--r--libcpp/files.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/libcpp/files.c b/libcpp/files.c
index a995071ad06..2f491224c6f 100644
--- a/libcpp/files.c
+++ b/libcpp/files.c
@@ -291,11 +291,13 @@ pch_open_file (cpp_reader *pfile, _cpp_file *file, bool *invalid_pch)
/* If the file is not included as first include from either the toplevel
file or the command-line it is not a valid use of PCH. */
- if (pfile->all_files
- && pfile->all_files->next_file
- && !(pfile->all_files->implicit_preinclude
- || pfile->all_files->next_file->implicit_preinclude))
- return false;
+ for (_cpp_file *f = pfile->all_files; f; f = f->next_file)
+ if (f->implicit_preinclude)
+ continue;
+ else if (f->main_file)
+ break;
+ else
+ return false;
flen = strlen (path);
len = flen + sizeof (extension);