diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -12168,7 +12168,7 @@ Sema::ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed, P); ExprResult R = getDerived().TransformExpr( E->getCallOperator()->getParamDecl(I)->getDefaultArg()); - P->setDefaultArg(R.get()); + getSema().SetParamDefaultArgument(P, R.get(), R.get()->getBeginLoc()); } } diff --git a/clang/test/SemaTemplate/instantiate-local-class.cpp b/clang/test/SemaTemplate/instantiate-local-class.cpp --- a/clang/test/SemaTemplate/instantiate-local-class.cpp +++ b/clang/test/SemaTemplate/instantiate-local-class.cpp @@ -486,3 +486,14 @@ } void g() { f(); } } + +namespace PR45000 { + template + void f(int x = [](T x = nullptr) -> int { return x; }()); + // expected-error@-1 2 {{cannot initialize a parameter of type 'int' with an rvalue of type 'nullptr_t'}} + // expected-note@-2 {{in instantiation of default function argument expression for 'operator()'}} + // expected-note@-3 2 {{passing argument to parameter 'x' here}} + + void g() { f(); } + // expected-note@-1 2 {{in instantiation of default function argument expression for 'f'}} +}