diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp --- a/clang/lib/Sema/SemaTemplateDeduction.cpp +++ b/clang/lib/Sema/SemaTemplateDeduction.cpp @@ -5804,10 +5804,10 @@ } bool TraverseTemplateName(TemplateName Template) { - if (auto *TTP = - dyn_cast(Template.getAsTemplateDecl())) - if (TTP->getDepth() == Depth) - Used[TTP->getIndex()] = true; + if (TemplateDecl *TD = Template.getAsTemplateDecl()) + if (auto *TTP = dyn_cast(TD)) + if (TTP->getDepth() == Depth) + Used[TTP->getIndex()] = true; RecursiveASTVisitor:: TraverseTemplateName(Template); return true;