From: Nathan Sidwell Date: Tue, 7 May 2019 18:13:57 +0000 (+0000) Subject: [libcpp] Reimplement mkdeps data structures X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=61145d937ba07e368d8251fd0ffe0b987b50a7b5;p=gcc.git [libcpp] Reimplement mkdeps data structures https://gcc.gnu.org/ml/gcc-patches/2019-05/msg00323.html * files.c (_cpp_stack_file): Empty filenames aren't dependencies. * mkdeps.c (deps_add_dep): Assert not empty. From-SVN: r270978 --- diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index df8da71f329..1c314ea112d 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,5 +1,8 @@ 2019-05-07 Nathan Sidwell + * files.c (_cpp_stack_file): Empty filenames aren't dependencies. + * mkdeps.c (deps_add_dep): Assert not empty. + * include/mkdeps.h (deps_write): Add PHONY arg. (deps_phony_targets): Delete. * init.c (cpp_finish): Just call deps_write. diff --git a/libcpp/files.c b/libcpp/files.c index b0ac22be6ba..3255cbfb6c8 100644 --- a/libcpp/files.c +++ b/libcpp/files.c @@ -906,11 +906,11 @@ _cpp_stack_file (cpp_reader *pfile, _cpp_file *file, bool import, sysp = MAX (pfile->buffer->sysp, file->dir->sysp); /* Add the file to the dependencies on its first inclusion. */ - if (CPP_OPTION (pfile, deps.style) > !!sysp && !file->stack_count) - { - if (!file->main_file || !CPP_OPTION (pfile, deps.ignore_main_file)) - deps_add_dep (pfile->deps, file->path); - } + if (!file->stack_count + && CPP_OPTION (pfile, deps.style) > !!sysp + && file->path[0] + && (!file->main_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. */ file->buffer_valid = false; diff --git a/libcpp/mkdeps.c b/libcpp/mkdeps.c index a9a050cf110..96cc49b9cc1 100644 --- a/libcpp/mkdeps.c +++ b/libcpp/mkdeps.c @@ -281,6 +281,8 @@ deps_add_default_target (struct mkdeps *d, const char *tgt) void deps_add_dep (struct mkdeps *d, const char *t) { + gcc_assert (*t); + t = apply_vpath (d, t); d->deps.push (xstrdup (t));