Don't allow template argument deduction to deduce a placeholder type,
ever. Fixes PR10939. llvm-svn: 140304
This commit is contained in:
parent
8cb0035ee9
commit
4ea5dec0e5
|
@ -977,6 +977,10 @@ DeduceTemplateArguments(Sema &S,
|
|||
// cv-list T
|
||||
if (const TemplateTypeParmType *TemplateTypeParm
|
||||
= Param->getAs<TemplateTypeParmType>()) {
|
||||
// Just skip any attempts to deduce from a placeholder type.
|
||||
if (Arg->isPlaceholderType())
|
||||
return Sema::TDK_Success;
|
||||
|
||||
unsigned Index = TemplateTypeParm->getIndex();
|
||||
bool RecanonicalizeArg = false;
|
||||
|
||||
|
|
|
@ -83,4 +83,21 @@ struct S {
|
|||
}
|
||||
};
|
||||
|
||||
namespace PR10939 {
|
||||
struct X {
|
||||
int method(int);
|
||||
int method(float);
|
||||
};
|
||||
|
||||
template<typename T> T g(T);
|
||||
|
||||
void f(X *x) {
|
||||
auto value = x->method; // expected-error{{variable 'value' with type 'auto' has incompatible initializer of type '<bound member function type>'}}
|
||||
if (value) { }
|
||||
|
||||
auto funcptr = &g<int>;
|
||||
int (*funcptr2)(int) = funcptr;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: if the initializer is a braced-init-list, deduce auto as std::initializer_list<T>.
|
||||
|
|
Loading…
Reference in New Issue