diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-02-16 21:36:18 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-02-16 21:36:18 +0000 |
commit | a86bc00d3efa6a92d5f78e052562cc0f8d4b6f6a (patch) | |
tree | 5a21877da35a7d218432968b929458672aaa8690 /clang/test/CXX/expr/expr.prim/expr.prim.lambda/templates.cpp | |
parent | 4fa6aec9fe5b3ea6571b7455d9d77efc18495d67 (diff) | |
download | bcm5719-llvm-a86bc00d3efa6a92d5f78e052562cc0f8d4b6f6a.tar.gz bcm5719-llvm-a86bc00d3efa6a92d5f78e052562cc0f8d4b6f6a.zip |
Lambda closure types are always considered to be like "local" classes,
even if they are not within a function scope. Teach template
instantiation to treat them as such, and make sure that we have a
local instantiation scope when instantiating default arguments and
static data members.
llvm-svn: 150725
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 | 33 |
1 files changed, 33 insertions, 0 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 14491cc3b20..49b9c66b1ce 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 @@ -114,3 +114,36 @@ namespace p5 { template void double_capture(NonConstCopy&); } + +namespace NonLocalLambdaInstantation { + template<typename T> + struct X { + static int value; + }; + + template<typename T> + int X<T>::value = []{ return T(); }(); // expected-error{{cannot initialize a variable of type 'int' with an rvalue of type 'int *'}} + + template int X<int>::value; + template int X<float>::value; + template int X<int*>::value; // expected-note{{in instantiation of static data member }} + + template<typename T> + void defaults(int x = []{ return T(); }()) { }; // expected-error{{cannot initialize a parameter of type 'int' with an rvalue of type 'int *'}} \ + // expected-note{{passing argument to parameter 'x' here}} + + void call_defaults() { + defaults<int>(); + defaults<float>(); + defaults<int*>(); // expected-note{{in instantiation of default function argument expression for 'defaults<int *>' required here}} + } + + template<typename T> + struct X2 { + 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}} +} |