aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2019-05-07 18:13:57 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2019-05-07 18:13:57 +0000
commit61145d937ba07e368d8251fd0ffe0b987b50a7b5 (patch)
tree7b1638fe2e3117ac734d21c0889d8c341f89c539 /libcpp
parent2ed6d245f7b79de73125edec51b2aa6db9ce3e6d (diff)
downloadgcc-61145d937ba07e368d8251fd0ffe0b987b50a7b5.zip
gcc-61145d937ba07e368d8251fd0ffe0b987b50a7b5.tar.gz
gcc-61145d937ba07e368d8251fd0ffe0b987b50a7b5.tar.bz2
[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
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog3
-rw-r--r--libcpp/files.c10
-rw-r--r--libcpp/mkdeps.c2
3 files changed, 10 insertions, 5 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index df8da71..1c314ea 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,5 +1,8 @@
2019-05-07 Nathan Sidwell <nathan@acm.org>
+ * 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 b0ac22b..3255cbf 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 a9a050c..96cc49b 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));