diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -1230,7 +1230,7 @@ // We recreated a local declaration, but not by instantiating it. There // may be pending dependent diagnostics to produce. - if (auto *DC = dyn_cast(Old)) + if (auto *DC = dyn_cast(Old); DC && DC->isDependentContext()) SemaRef.PerformDependentDiagnostics(DC, TemplateArgs); } diff --git a/clang/test/SemaCXX/lambda-unevaluated.cpp b/clang/test/SemaCXX/lambda-unevaluated.cpp --- a/clang/test/SemaCXX/lambda-unevaluated.cpp +++ b/clang/test/SemaCXX/lambda-unevaluated.cpp @@ -144,3 +144,7 @@ using d = decltype(sizeof([] static { return 0; })); } + +namespace lambda_in_trailing_decltype { +auto x = ([](auto) -> decltype([] {}()) {}(0), 2); +}