diff options
author | Reid Kleckner <reid@kleckner.net> | 2014-11-17 23:36:45 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2014-11-17 23:36:45 +0000 |
commit | d60b82f93eee090650d848c45f34dcf9d3ffa0ea (patch) | |
tree | 248e4025074de0fb3c720dbad97942efe0d18b08 /clang/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp | |
parent | f39c3b8108c34148e6f03cbd0907619020c1a9eb (diff) | |
download | bcm5719-llvm-d60b82f93eee090650d848c45f34dcf9d3ffa0ea.tar.gz bcm5719-llvm-d60b82f93eee090650d848c45f34dcf9d3ffa0ea.zip |
Handle use of default member initializers before end of outermost class
Specifically, when we have this situation:
struct A {
template <typename T> struct B {
int m1 = sizeof(A);
};
B<int> m2;
};
We can't parse m1's initializer eagerly because we need A to be
complete. Therefore we wait until the end of A's class scope to parse
it. However, we can trigger instantiation of B before the end of A,
which will attempt to instantiate the field decls eagerly, and it would
build a bad field decl instantiation that said it had an initializer but
actually lacked one.
Fixed by deferring instantiation of default member initializers until
they are needed during constructor analysis. This addresses a long
standing FIXME in the code.
Fixes PR19195.
Reviewed By: rsmith
Differential Revision: http://reviews.llvm.org/D5690
llvm-svn: 222192
Diffstat (limited to 'clang/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp')
-rw-r--r-- | clang/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp index 407b083231a..90cbf02b2a6 100644 --- a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp +++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp @@ -140,11 +140,11 @@ namespace NonLocalLambdaInstantation { } template<typename T> - struct X2 { + struct X2 { // expected-note{{in instantiation of default member initializer 'NonLocalLambdaInstantation::X2<int *>::x' requested here}} int x = []{ return T(); }(); // expected-error{{cannot initialize a member subobject of type 'int' with an rvalue of type 'int *'}} }; X2<int> x2i; X2<float> x2f; - X2<int*> x2ip; // expected-note{{in instantiation of template class 'NonLocalLambdaInstantation::X2<int *>' requested here}} + X2<int*> x2ip; // expected-note{{implicit default constructor for 'NonLocalLambdaInstantation::X2<int *>' first required here}} } |