aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2019-06-26 12:58:39 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2019-06-26 12:58:39 +0000
commit66d7749bce891ee8707c0c63ceffeac1a95b4d78 (patch)
treeaa708b1c46212a60bc2e9fd101c299abd0c61a65
parent93a090cf2afdf3749c01bb55112c6e97cf38adc3 (diff)
downloadgcc-66d7749bce891ee8707c0c63ceffeac1a95b4d78.zip
gcc-66d7749bce891ee8707c0c63ceffeac1a95b4d78.tar.gz
gcc-66d7749bce891ee8707c0c63ceffeac1a95b4d78.tar.bz2
[PR preprocessor/90927] Fixe dependency output
https://gcc.gnu.org/ml/gcc-patches/2019-06/msg01664.html libcpp/ PR preprocessor/90927 * mkdeps.c (mkdeps::vec::operator[]): Add non-const variant. (deps_add_target): Deal with out of order unquoted targets. gcc/testsuite/ * c-c++-common/pr90927.c: New. From-SVN: r272692
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/c-c++-common/pr90927.c6
-rw-r--r--libcpp/ChangeLog6
-rw-r--r--libcpp/mkdeps.c18
4 files changed, 31 insertions, 3 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b16e23a..83cef68 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2019-06-26 Nathan Sidwell <nathan@acm.org>
+
+ * c-c++-common/pr90927.c: New.
+
2019-06-26 Richard Biener <rguenther@suse.de>
PR ipa/90982
diff --git a/gcc/testsuite/c-c++-common/pr90927.c b/gcc/testsuite/c-c++-common/pr90927.c
new file mode 100644
index 0000000..6b0d348
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr90927.c
@@ -0,0 +1,6 @@
+/* { dg-do preprocess } */
+/* { dg-additional-options "-M -MQ b\\\$ob -MT b\\\$ill" } */
+
+int i;
+
+/* { dg-final { scan-file pr90927.i {b\$ill b\$\$ob:} } } */
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index 71a0949..1575d4b 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,9 @@
+2019-06-26 Nathan Sidwell <nathan@acm.org>
+
+ PR preprocessor/90927
+ * mkdeps.c (mkdeps::vec::operator[]): Add non-const variant.
+ (deps_add_target): Deal with out of order unquoted targets.
+
2019-05-19 Andrew Pinski <apinski@marvell.com>
PR pch/81721
diff --git a/libcpp/mkdeps.c b/libcpp/mkdeps.c
index 96cc49b..676ae12 100644
--- a/libcpp/mkdeps.c
+++ b/libcpp/mkdeps.c
@@ -59,6 +59,10 @@ public:
{
return ary[ix];
}
+ T &operator[] (unsigned ix)
+ {
+ return ary[ix];
+ }
void push (const T &elt)
{
if (num == alloc)
@@ -235,14 +239,22 @@ deps_free (struct mkdeps *d)
void
deps_add_target (struct mkdeps *d, const char *t, int quote)
{
- t = apply_vpath (d, t);
+ t = xstrdup (apply_vpath (d, t));
+
if (!quote)
{
- gcc_assert (d->quote_lwm == d->targets.size ());
+ /* Sometimes unquoted items are added after quoted ones.
+ Swap out the lowest quoted. */
+ if (d->quote_lwm != d->targets.size ())
+ {
+ const char *lowest = d->targets[d->quote_lwm];
+ d->targets[d->quote_lwm] = t;
+ t = lowest;
+ }
d->quote_lwm++;
}
- d->targets.push (xstrdup (t));
+ d->targets.push (t);
}
/* Sets the default target if none has been given already. An empty