diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-11-19 21:07:04 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-11-19 21:07:04 +0000 |
commit | 1334490e37b5e10d3ee699c445290c3daf2d877e (patch) | |
tree | ef43a85c97740ad27a5075978566b1857b9f107d /lib/Sema/SemaTemplateDeduction.cpp | |
parent | 5f96d3cbdd72f3074dfb544be67441ed2199a346 (diff) |
Further fixes when thiscall is the default for methods.
The previous patches tried to deduce the correct function type. I now realize
this is not possible in general. Consider
class foo {
template <typename T> static void bar(T v);
};
extern template void foo::bar(const void *);
We will only know that bar is static after a lookup, so we have to handle this
in the template instantiation code.
This patch reverts my previous two changes (but not the tests) and instead
handles the issue in DeduceTemplateArguments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195154 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateDeduction.cpp')
-rw-r--r-- | lib/Sema/SemaTemplateDeduction.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp index b401db21a8..56df8bab9b 100644 --- a/lib/Sema/SemaTemplateDeduction.cpp +++ b/lib/Sema/SemaTemplateDeduction.cpp @@ -3538,6 +3538,23 @@ Sema::DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate, TemplateParameterList *TemplateParams = FunctionTemplate->getTemplateParameters(); QualType FunctionType = Function->getType(); + if (!InOverloadResolution && !ArgFunctionType.isNull()) { + const FunctionProtoType *FunctionTypeP = + FunctionType->castAs<FunctionProtoType>(); + CallingConv CC = FunctionTypeP->getCallConv(); + bool NoReturn = FunctionTypeP->getNoReturnAttr(); + const FunctionProtoType *ArgFunctionTypeP = + ArgFunctionType->getAs<FunctionProtoType>(); + if (ArgFunctionTypeP->getCallConv() != CC || + ArgFunctionTypeP->getNoReturnAttr() != NoReturn) { + FunctionType::ExtInfo EI = + ArgFunctionTypeP->getExtInfo().withCallingConv(CC); + EI = EI.withNoReturn(NoReturn); + ArgFunctionTypeP = cast<FunctionProtoType>( + Context.adjustFunctionType(ArgFunctionTypeP, EI)); + ArgFunctionType = QualType(ArgFunctionTypeP, 0); + } + } // Substitute any explicit template arguments. LocalInstantiationScope InstScope(*this); |