@@ -69,8 +69,8 @@ class ExtractTypeForDeductionGuide
69
69
ExtractTypeForDeductionGuide (
70
70
Sema &SemaRef,
71
71
llvm::SmallVectorImpl<TypedefNameDecl *> &MaterializedTypedefs,
72
- ClassTemplateDecl *NestedPattern,
73
- const MultiLevelTemplateArgumentList *OuterInstantiationArgs)
72
+ ClassTemplateDecl *NestedPattern = nullptr ,
73
+ const MultiLevelTemplateArgumentList *OuterInstantiationArgs = nullptr )
74
74
: Base(SemaRef), MaterializedTypedefs(MaterializedTypedefs),
75
75
NestedPattern (NestedPattern),
76
76
OuterInstantiationArgs(OuterInstantiationArgs) {
@@ -1263,10 +1263,25 @@ FunctionTemplateDecl *DeclareAggregateDeductionGuideForTypeAlias(
1263
1263
getRHSTemplateDeclAndArgs (SemaRef, AliasTemplate).first ;
1264
1264
if (!RHSTemplate)
1265
1265
return nullptr ;
1266
+
1267
+ llvm::SmallVector<TypedefNameDecl *> TypedefDecls;
1268
+ llvm::SmallVector<QualType> NewParamTypes;
1269
+ ExtractTypeForDeductionGuide TypeAliasTransformer (SemaRef, TypedefDecls);
1270
+ for (QualType P : ParamTypes) {
1271
+ QualType Type = TypeAliasTransformer.TransformType (P);
1272
+ if (Type.isNull ())
1273
+ return nullptr ;
1274
+ NewParamTypes.push_back (Type);
1275
+ }
1276
+
1266
1277
auto *RHSDeductionGuide = SemaRef.DeclareAggregateDeductionGuideFromInitList (
1267
- RHSTemplate, ParamTypes , Loc);
1278
+ RHSTemplate, NewParamTypes , Loc);
1268
1279
if (!RHSDeductionGuide)
1269
1280
return nullptr ;
1281
+
1282
+ for (TypedefNameDecl *TD : TypedefDecls)
1283
+ TD->setDeclContext (RHSDeductionGuide->getTemplatedDecl ());
1284
+
1270
1285
return BuildDeductionGuideForTypeAlias (SemaRef, AliasTemplate,
1271
1286
RHSDeductionGuide, Loc);
1272
1287
}
0 commit comments