forked from OSchip/llvm-project
When performing template argument deduction, match Objective C pointers
against pointer patterns. llvm-svn: 103706
This commit is contained in:
parent
7100860ef5
commit
bb4ea81ab9
|
@ -482,14 +482,20 @@ DeduceTemplateArguments(Sema &S,
|
|||
|
||||
// T *
|
||||
case Type::Pointer: {
|
||||
const PointerType *PointerArg = Arg->getAs<PointerType>();
|
||||
if (!PointerArg)
|
||||
QualType PointeeType;
|
||||
if (const PointerType *PointerArg = Arg->getAs<PointerType>()) {
|
||||
PointeeType = PointerArg->getPointeeType();
|
||||
} else if (const ObjCObjectPointerType *PointerArg
|
||||
= Arg->getAs<ObjCObjectPointerType>()) {
|
||||
PointeeType = PointerArg->getPointeeType();
|
||||
} else {
|
||||
return Sema::TDK_NonDeducedMismatch;
|
||||
}
|
||||
|
||||
unsigned SubTDF = TDF & (TDF_IgnoreQualifiers | TDF_DerivedClass);
|
||||
return DeduceTemplateArguments(S, TemplateParams,
|
||||
cast<PointerType>(Param)->getPointeeType(),
|
||||
PointerArg->getPointeeType(),
|
||||
PointeeType,
|
||||
Info, Deduced, SubTDF);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
||||
|
||||
@class NSString;
|
||||
|
||||
// Reduced from WebKit.
|
||||
namespace test0 {
|
||||
template <typename T> struct RemovePointer {
|
||||
typedef T Type;
|
||||
};
|
||||
|
||||
template <typename T> struct RemovePointer<T*> {
|
||||
typedef T Type;
|
||||
};
|
||||
|
||||
template <typename T> struct RetainPtr {
|
||||
typedef typename RemovePointer<T>::Type ValueType;
|
||||
typedef ValueType* PtrType;
|
||||
RetainPtr(PtrType ptr);
|
||||
};
|
||||
|
||||
void test(NSString *S) {
|
||||
RetainPtr<NSString*> ptr(S);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue