On Tue, Nov 19, 2013 at 8:43 AM, Rafael Espíndola <
[email protected]> wrote:
> The previous patches tried to deduce the correct function type. I now
> don't think that is possible in general. Consider
>
> class foo {
> template <typename T> static void bar(T v);
> };
> extern template void foo::bar(const void *);
>
> We will only now that bar is static after a lookup, so it looks like
> we have to handle this in the template instantiation code. This also
> makes me suspicious of the previous users of FreeFunction always being
> correct.
>
Yes, the calling convention can always change at decl merging time due to
static methods or declarations with explicit conventions. Templates make
that redeclaration lookup complicated.
The attached patch reverts my previous two (but not the tests) and
> instead handles the issue in DeduceTemplateArguments.
>
+ if (!InOverloadResolution && !ArgFunctionType.isNull()) {
+ CallingConv CC =
FunctionType->getAs<FunctionProtoType>()->getCallConv();
+ const FunctionProtoType *ArgFunctionTypeP =
+ ArgFunctionType->getAs<FunctionProtoType>();
Use castAs<> if you're going to dereference unconditionally.
+ if (ArgFunctionTypeP->getCallConv() != CC) {
+ FunctionType::ExtInfo EI =
+ ArgFunctionTypeP->getExtInfo().withCallingConv(CC);
+ ArgFunctionTypeP = cast<FunctionProtoType>(
+ Context.adjustFunctionType(ArgFunctionTypeP, EI));
+ ArgFunctionType = QualType(ArgFunctionTypeP, 0);
+ }
+ }
This looks like the logic I added to
Sema::CheckFunctionTemplateSpecialization() in r190377. If you add this,
can we remove it? If not, can we share it? See also the related
ExactlyInt test case.
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits