summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2018-02-09 09:04:00 +0000
committerHans Wennborg <hans@hanshq.net>2018-02-09 09:04:00 +0000
commit4a005620928c39874a0177ec97d84e636ab8dbfc (patch)
tree72a125ab4504b114d4a7b9c3477a671801fe4063 /test
parent1d5b6bd0b8ee0cad2a92f45245b5fbbf23c48ef3 (diff)
Merging r324537:
------------------------------------------------------------------------ r324537 | rsmith | 2018-02-07 23:25:16 +0100 (Wed, 07 Feb 2018) | 14 lines PR36055: fix computation of *-dependence in nested initializer lists. When we synthesize an implicit inner initializer list when analyzing an outer initializer list, we add it to the outer list immediately, and then fill in the inner list. This gives the outer list no chance to update its *-dependence bits with those of the completed inner list. To fix this, re-add the inner list to the outer list once it's completed. Note that we do not recompute the *-dependence bits from scratch when we complete an outer list; this would give the wrong result for the case where a designated initializer overwrites a dependent initializer with a non-dependent one. The resulting list in that case should still be dependent, even though all traces of the dependence were removed from the semantic form. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_60@324719 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/SemaCXX/init-expr-crash.cpp8
-rw-r--r--test/SemaTemplate/instantiate-init.cpp14
2 files changed, 22 insertions, 0 deletions
diff --git a/test/SemaCXX/init-expr-crash.cpp b/test/SemaCXX/init-expr-crash.cpp
index 407da78e60..201ab03955 100644
--- a/test/SemaCXX/init-expr-crash.cpp
+++ b/test/SemaCXX/init-expr-crash.cpp
@@ -29,3 +29,11 @@ template <class T> struct B {
return 0;
}
};
+
+// This test checks for a crash that resulted from us miscomputing the
+// dependence of a nested initializer list.
+template<int> struct X {
+ static constexpr int n = 4;
+ static constexpr int a[1][1] = {n};
+};
+
diff --git a/test/SemaTemplate/instantiate-init.cpp b/test/SemaTemplate/instantiate-init.cpp
index 244e94f6d6..51fa6955d0 100644
--- a/test/SemaTemplate/instantiate-init.cpp
+++ b/test/SemaTemplate/instantiate-init.cpp
@@ -142,3 +142,17 @@ namespace ReturnStmtIsInitialization {
template<typename T> X f() { return {}; }
auto &&x = f<void>();
}
+
+namespace InitListUpdate {
+ struct A { int n; };
+ using AA = A[1];
+
+ // Check that an init list update doesn't "lose" the pack-ness of an expression.
+ template <int... N> void f() {
+ g(AA{0, [0].n = N} ...); // expected-warning 3{{overrides prior init}} expected-note 3{{previous init}}
+ g(AA{N, [0].n = 0} ...); // expected-warning 3{{overrides prior init}} expected-note 3{{previous init}}
+ };
+
+ void g(AA, AA);
+ void h() { f<1, 2>(); } // expected-note {{instantiation of}}
+}