diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 858aabf8a8b8..21ddd473636b 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -1017,10 +1017,19 @@ Decl *TemplateDeclInstantiator::VisitCXXRecordDecl(CXXRecordDecl *D) { static QualType adjustFunctionTypeForInstantiation(ASTContext &Context, FunctionDecl *D, TypeSourceInfo *TInfo) { - const FunctionType *OrigFunc = D->getType()->castAs(); - const FunctionType *NewFunc = TInfo->getType()->castAs(); - return QualType(Context.adjustFunctionType(NewFunc, OrigFunc->getExtInfo()), - 0); + const FunctionProtoType *OrigFunc + = D->getType()->castAs(); + const FunctionProtoType *NewFunc + = TInfo->getType()->castAs(); + if (OrigFunc->getExtInfo() == NewFunc->getExtInfo()) + return TInfo->getType(); + + FunctionProtoType::ExtProtoInfo NewEPI = NewFunc->getExtProtoInfo(); + NewEPI.ExtInfo = OrigFunc->getExtInfo(); + return Context.getFunctionType(NewFunc->getResultType(), + NewFunc->arg_type_begin(), + NewFunc->getNumArgs(), + NewEPI); } /// Normal class members are of more specific types and therefore