diff options
| author | Aaron Puchert <aaronpuchert@alice-dsl.net> | 2020-04-22 20:05:36 +0200 |
|---|---|---|
| committer | Tom Stellard <tstellar@redhat.com> | 2020-05-06 20:08:58 -0700 |
| commit | 9c80516d3e3aae34b7dd7ee0204170c888fd7235 (patch) | |
| tree | a8f1b66337fdd28931a8b7193512d0eff97fbbeb /clang/test/SemaTemplate/instantiate-local-class.cpp | |
| parent | 1d1469ab64294a6a18410310e0f77f590ee4ba7c (diff) | |
| download | bcm5719-llvm-9c80516d3e3aae34b7dd7ee0204170c888fd7235.tar.gz bcm5719-llvm-9c80516d3e3aae34b7dd7ee0204170c888fd7235.zip | |
PR45000: Let Sema::SubstParmVarDecl handle default args of lambdas in initializers
Summary:
We extend the behavior for local functions and methods of local classes
to lambdas in variable initializers. The initializer is not a separate
scope, but we treat it as such.
We also remove the (faulty) instantiation of default arguments in
TreeTransform::TransformLambdaExpr, because it doesn't do proper
initialization, and if it did, we would do it twice (and thus also emit
eventual errors twice).
Reviewed By: rsmith
Differential Revision: https://reviews.llvm.org/D76038
(cherry picked from commit f43859a099fa3587123717be941fa63ba8d0d4f2)
Diffstat (limited to 'clang/test/SemaTemplate/instantiate-local-class.cpp')
| -rw-r--r-- | clang/test/SemaTemplate/instantiate-local-class.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/test/SemaTemplate/instantiate-local-class.cpp b/clang/test/SemaTemplate/instantiate-local-class.cpp index eaff4c4bbc8..550c59d6177 100644 --- a/clang/test/SemaTemplate/instantiate-local-class.cpp +++ b/clang/test/SemaTemplate/instantiate-local-class.cpp @@ -486,3 +486,16 @@ namespace anon_union_default_member_init { } void g() { f<int>(); } } + +namespace PR45000 { + template <typename T> + void f(int x = [](T x = nullptr) -> int { return x; }()); + // expected-error@-1 {{cannot initialize a parameter of type 'int' with an rvalue of type 'nullptr_t'}} + // expected-note@-2 {{passing argument to parameter 'x' here}} + // expected-error@-3 {{no matching function for call}} + // expected-note@-4 {{candidate function not viable: requires single argument 'x', but no arguments were provided}} + // expected-note@-5 {{conversion candidate of type 'auto (*)(int) -> int'}} + + void g() { f<int>(); } + // expected-note@-1 {{in instantiation of default function argument expression for 'f<int>' required here}} +} |

