aboutsummaryrefslogtreecommitdiff
path: root/gcc/cpplib.c
diff options
context:
space:
mode:
authorPer Bothner <bothner@gcc.gnu.org>1995-04-06 23:20:52 -0700
committerPer Bothner <bothner@gcc.gnu.org>1995-04-06 23:20:52 -0700
commit6bac1e649626ba7afbe4100dfbaa26f6b361129c (patch)
tree87657b8c635c0412c37882856a32612717a80a63 /gcc/cpplib.c
parent56c667474e64c95d8a69592d54b40db9f6ba29d1 (diff)
downloadgcc-6bac1e649626ba7afbe4100dfbaa26f6b361129c.zip
gcc-6bac1e649626ba7afbe4100dfbaa26f6b361129c.tar.gz
gcc-6bac1e649626ba7afbe4100dfbaa26f6b361129c.tar.bz2
cpplib.c (SELF_DIR_DUMMY): New macro.
* cpplib.c (SELF_DIR_DUMMY): New macro. (do_include): Don't pass searchptr to finclude if it is dsp, since that is on the stack, and would cause a dangling pointer. If handling #include_next, recognize SELF_DIR_DUMMY. From-SVN: r9320
Diffstat (limited to 'gcc/cpplib.c')
-rw-r--r--gcc/cpplib.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/gcc/cpplib.c b/gcc/cpplib.c
index 6589f80..1ba96d82 100644
--- a/gcc/cpplib.c
+++ b/gcc/cpplib.c
@@ -358,6 +358,10 @@ struct file_name_list
int got_name_map;
};
+/* If a buffer's dir field is SELF_DIR_DUMMY, it means the file was found
+ via the same directory as the file that #included it. */
+#define SELF_DIR_DUMMY ((struct file_name_list*)(~0))
+
/* #include "file" looks in source file dir, then stack. */
/* #include <file> just looks in the stack. */
/* -I directories are added to the end, then the defaults are added. */
@@ -3338,7 +3342,9 @@ do_include (pfile, keyword, unused1, unused2)
{
/* fp->dir is null if the containing file was specified with
an absolute file name. In that case, don't skip anything. */
- if (fp->dir)
+ if (fp->dir == SELF_DIR_DUMMY)
+ search_start = CPP_OPTIONS (pfile)->include;
+ else if (fp->dir)
search_start = fp->dir->next;
break;
}
@@ -3580,7 +3586,7 @@ do_include (pfile, keyword, unused1, unused2)
/* Actually process the file */
if (finclude (pfile, f, fname, is_system_include (pfile, fname),
- searchptr))
+ searchptr != dsp ? searchptr : SELF_DIR_DUMMY))
{
output_line_command (pfile, 0, enter_file);
pfile->only_seen_white = 2;
@@ -5620,7 +5626,7 @@ open_include_file (filename, searchptr)
"system" include directories (as decided by the `is_system_include'
function above).
DIRPTR is the link in the dir path through which this file was found,
- or 0 if the file name was absolute.
+ or 0 if the file name was absolute or via the current directory.
Return 1 on success, 0 on failure. */
static int
@@ -6241,7 +6247,7 @@ push_parse_file (pfile, fname)
pedwarn ("file does not end in newline");
#endif
- if (finclude (pfile, f, fname, 0, 0))
+ if (finclude (pfile, f, fname, 0, NULL_PTR))
output_line_command (pfile, 0, same_file);
return SUCCESS_EXIT_CODE;
}