Properly set up the DeclContext for parameters of implicit deduction guides;
this is needed for deferred instantiation of default arguments.

llvm-svn: 295379
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 5470017..4c5f3be 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -1677,6 +1677,9 @@
                                  bool Explicit, TypeSourceInfo *TInfo,
                                  SourceLocation LocStart, SourceLocation Loc,
                                  SourceLocation LocEnd) {
+    ArrayRef<ParmVarDecl *> Params =
+        TInfo->getTypeLoc().castAs<FunctionProtoTypeLoc>().getParams();
+
     // Build the implicit deduction guide template.
     auto *Guide = FunctionDecl::Create(SemaRef.Context, DC, LocStart, Loc,
                                        DeductionGuideName, TInfo->getType(),
@@ -1685,8 +1688,10 @@
     if (Explicit)
       Guide->setExplicitSpecified();
     Guide->setRangeEnd(LocEnd);
-    Guide->setParams(
-        TInfo->getTypeLoc().castAs<FunctionProtoTypeLoc>().getParams());
+    Guide->setParams(Params);
+
+    for (auto *Param : Params)
+      Param->setDeclContext(Guide);
 
     auto *GuideTemplate = FunctionTemplateDecl::Create(
         SemaRef.Context, DC, Loc, DeductionGuideName, TemplateParams, Guide);