This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] fix #include_next with absolute paths


this occurs with OpenOffice, using STLport, with gcc 4.3.  The new 4.3 
headers use #include_next in more places it seems (otherwise it would have 
happened earlier, as 4.2 has the same problem).  STLport includes GCC 
headers via absolute path (questionable but valid), and the include_next 
in them then will break with messages like this:

$> g++ test-abs.cxx
In file included from test-abs.cxx:1:
/usr/include/c++/4.3.0/cstddef:48:25: error: no include path in which to
search for stddef.h

This is because the test for when headers were found in absolute paths is 
broken since quite some time already.  In former times (still in 
gcc/cppfiles.c) it was testing a local member of file which only was set 
once the path was determined not to be absolute.

In the current scheme we return &pfile->no_search_path as directory 
entity if the path is absolute.  In particular we return a non-NULL value 
there.  So for absolute paths file->dir never will be NULL, but instead 
will be &pfile->no_search_path.  So the test meanwhile is incorrect.  
Fixed with the attached patch.  Testcases are a bit complicated as the 
feature in particular is about absolute paths, which for users will vary.

Anyway, regstrapped on i686.  Okay for mainline?

	* files.c (search_path_head): Fix check for absolute paths.

Index: libcpp/files.c
--- libcpp/files.c	(revision 130219)
+++ libcpp/files.c	(working copy)
@@ -837,7 +837,8 @@ search_path_head (cpp_reader *pfile, con
   /* For #include_next, skip in the search path past the dir in which
      the current file was found, but if it was found via an absolute
      path use the normal search logic.  */
-  if (type == IT_INCLUDE_NEXT && file->dir)
+  if (type == IT_INCLUDE_NEXT && file->dir
+      && file->dir != &pfile->no_search_path)
     dir = file->dir->next;
   else if (angle_brackets)
     dir = pfile->bracket_include;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]