diff options
Diffstat (limited to 'libcpp/files.c')
-rw-r--r-- | libcpp/files.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/libcpp/files.c b/libcpp/files.c index b5d9f30..ba52d2b 100644 --- a/libcpp/files.c +++ b/libcpp/files.c @@ -103,9 +103,6 @@ struct _cpp_file /* If read() failed before. */ bool dont_read : 1; - /* If this file is the main file. */ - bool main_file : 1; - /* If BUFFER above contains the true contents of the file. */ bool buffer_valid : 1; @@ -186,7 +183,7 @@ static void open_file_failed (cpp_reader *pfile, _cpp_file *file, int, location_t); static struct cpp_file_hash_entry *search_cache (struct cpp_file_hash_entry *head, const cpp_dir *start_dir); -static _cpp_file *make_cpp_file (cpp_reader *, cpp_dir *, const char *fname); +static _cpp_file *make_cpp_file (cpp_dir *, const char *fname); static void destroy_cpp_file (_cpp_file *); static cpp_dir *make_cpp_dir (cpp_reader *, const char *dir_name, int sysp); static void allocate_file_hash_entries (cpp_reader *pfile); @@ -299,7 +296,7 @@ pch_open_file (cpp_reader *pfile, _cpp_file *file, bool *invalid_pch) for (_cpp_file *f = pfile->all_files; f; f = f->next_file) if (f->implicit_preinclude) continue; - else if (f->main_file) + else if (pfile->main_file == f) break; else return false; @@ -528,7 +525,7 @@ _cpp_find_file (cpp_reader *pfile, const char *fname, cpp_dir *start_dir, if (entry) return entry->u.file; - _cpp_file *file = make_cpp_file (pfile, start_dir, fname); + _cpp_file *file = make_cpp_file (start_dir, fname); file->implicit_preinclude = (kind == _cpp_FFK_PRE_INCLUDE || (pfile->buffer && pfile->buffer->file->implicit_preinclude)); @@ -865,7 +862,7 @@ has_unique_contents (cpp_reader *pfile, _cpp_file *file, bool import, { /* We already have a buffer but it is not valid, because the file is still stacked. Make a new one. */ - ref_file = make_cpp_file (pfile, f->dir, f->name); + ref_file = make_cpp_file (f->dir, f->name); ref_file->path = f->path; } else @@ -951,7 +948,8 @@ _cpp_stack_file (cpp_reader *pfile, _cpp_file *file, include_type type, if (CPP_OPTION (pfile, deps.style) > (sysp != 0) && !file->stack_count && file->path[0] - && !(file->main_file && CPP_OPTION (pfile, deps.ignore_main_file))) + && !(pfile->main_file == file + && CPP_OPTION (pfile, deps.ignore_main_file))) deps_add_dep (pfile->deps, file->path); /* Clear buffer_valid since _cpp_clean_line messes it up. */ @@ -1187,12 +1185,9 @@ search_cache (struct cpp_file_hash_entry *head, const cpp_dir *start_dir) /* Allocate a new _cpp_file structure. */ static _cpp_file * -make_cpp_file (cpp_reader *pfile, cpp_dir *dir, const char *fname) +make_cpp_file (cpp_dir *dir, const char *fname) { - _cpp_file *file; - - file = XCNEW (_cpp_file); - file->main_file = !pfile->buffer; + _cpp_file *file = XCNEW (_cpp_file); file->fd = -1; file->dir = dir; file->name = xstrdup (fname); @@ -1452,6 +1447,7 @@ cpp_change_file (cpp_reader *pfile, enum lc_reason reason, struct report_missing_guard_data { + cpp_reader *pfile; const char **paths; size_t count; }; @@ -1470,8 +1466,10 @@ report_missing_guard (void **slot, void *d) _cpp_file *file = entry->u.file; /* We don't want MI guard advice for the main file. */ - if (!file->once_only && file->cmacro == NULL - && file->stack_count == 1 && !file->main_file) + if (!file->once_only + && file->cmacro == NULL + && file->stack_count == 1 + && data->pfile->main_file != file) { if (data->paths == NULL) { @@ -1501,6 +1499,7 @@ _cpp_report_missing_guards (cpp_reader *pfile) { struct report_missing_guard_data data; + data.pfile = pfile; data.paths = NULL; data.count = htab_elements (pfile->file_hash); htab_traverse (pfile->file_hash, report_missing_guard, &data); |