public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug preprocessor/104471] ICE with -nostdinc: NULL directory in find_file Date: Fri, 09 Dec 2022 15:06:03 +0000 [thread overview] Message-ID: <bug-104471-4-fe8EQLr23h@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-104471-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104471 --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- This patch should fix the issue (I might get to it in a few weeks though): diff --git a/libcpp/files.cc b/libcpp/files.cc index a18b1caf48d..eb90fa4f65a 100644 --- a/libcpp/files.cc +++ b/libcpp/files.cc @@ -177,7 +177,7 @@ static bool read_file_guts (cpp_reader *pfile, _cpp_file *file, static bool read_file (cpp_reader *pfile, _cpp_file *file, location_t loc); static struct cpp_dir *search_path_head (cpp_reader *, const char *fname, - int angle_brackets, enum include_type); + int angle_brackets, enum include_type, bool = true); static const char *dir_name_of_file (_cpp_file *file); static void open_file_failed (cpp_reader *pfile, _cpp_file *file, int, location_t); @@ -1026,7 +1026,7 @@ _cpp_mark_file_once_only (cpp_reader *pfile, _cpp_file *file) nothing left in the path, returns NULL. */ static struct cpp_dir * search_path_head (cpp_reader *pfile, const char *fname, int angle_brackets, - enum include_type type) + enum include_type type, bool canerror) { cpp_dir *dir; _cpp_file *file; @@ -1055,7 +1055,7 @@ search_path_head (cpp_reader *pfile, const char *fname, int angle_brackets, return make_cpp_dir (pfile, dir_name_of_file (file), pfile->buffer ? pfile->buffer->sysp : 0); - if (dir == NULL) + if (canerror && dir == NULL) cpp_error (pfile, CPP_DL_ERROR, "no include path in which to search for %s", fname); @@ -2144,7 +2144,9 @@ bool _cpp_has_header (cpp_reader *pfile, const char *fname, int angle_brackets, enum include_type type) { - cpp_dir *start_dir = search_path_head (pfile, fname, angle_brackets, type); + cpp_dir *start_dir = search_path_head (pfile, fname, angle_brackets, type, false); + if (!start_dir) + return false; _cpp_file *file = _cpp_find_file (pfile, fname, start_dir, angle_brackets, _cpp_FFK_HAS_INCLUDE, 0); return file->err_no != ENOENT;
prev parent reply other threads:[~2022-12-09 15:06 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-02-09 18:28 [Bug c/104471] New: " gscfq@t-online.de 2022-12-09 14:58 ` [Bug preprocessor/104471] " pinskia at gcc dot gnu.org 2022-12-09 15:06 ` pinskia at gcc dot gnu.org [this message]
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-104471-4-fe8EQLr23h@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).