Bootstrapped and regtested on x86_64-pc-linux-gnu, OK for trunk/15?
I wasn't able to work out a good way to test this with dejagnu.

-- >8 --

When using -fsearch-include-path, we prepend the result of
search_path_head to the provided filenames, which for non-absolute paths
will return "./".  At this point, stdin is represented by the empty
string, and so prepending "./" confuses 'open_file'.  This patch fixes
the issue by treating stdin as-if it were an absolute path.

        PR c++/119756

libcpp/ChangeLog:

        * files.cc (search_path_head): Also treat empty string (stdin)
        as an absolute path.

Signed-off-by: Nathaniel Shead <[email protected]>
---
 libcpp/files.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcpp/files.cc b/libcpp/files.cc
index 9ab3aae4c92..c0ccbe9b212 100644
--- a/libcpp/files.cc
+++ b/libcpp/files.cc
@@ -1095,7 +1095,7 @@ search_path_head (cpp_reader *pfile, const char *fname, 
int angle_brackets,
   cpp_dir *dir;
   _cpp_file *file;
 
-  if (IS_ABSOLUTE_PATH (fname))
+  if (IS_ABSOLUTE_PATH (fname) || *fname == '\0')
     return &pfile->no_search_path;
 
   /* pfile->buffer is NULL when processing an -include command-line flag.  */
-- 
2.51.0

Reply via email to