From d28f0412e40612785175c53def8ed2dee0ae1c0a Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 22 Feb 2010 17:06:41 +0000 Subject: [PATCH] Do not require a complete type when checking for a pointer conversion between cv1 T* and cv2 T*. llvm-svn: 96787 --- clang/lib/Sema/SemaOverload.cpp | 1 + .../CXX/temp/temp.spec/temp.explicit/p6.cpp | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 1c6fd17c3813..b3b665c1b6df 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -1094,6 +1094,7 @@ bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType, // here. That is handled by CheckPointerConversion. if (getLangOptions().CPlusPlus && FromPointeeType->isRecordType() && ToPointeeType->isRecordType() && + !Context.hasSameUnqualifiedType(FromPointeeType, ToPointeeType) && !RequireCompleteType(From->getLocStart(), FromPointeeType, PDiag()) && IsDerivedFrom(FromPointeeType, ToPointeeType)) { ConvertedType = BuildSimilarlyQualifiedPointerType(FromTypePtr, diff --git a/clang/test/CXX/temp/temp.spec/temp.explicit/p6.cpp b/clang/test/CXX/temp/temp.spec/temp.explicit/p6.cpp index 44ce41b6f957..13822725b5bd 100644 --- a/clang/test/CXX/temp/temp.spec/temp.explicit/p6.cpp +++ b/clang/test/CXX/temp/temp.spec/temp.explicit/p6.cpp @@ -12,3 +12,24 @@ template void f0(T, U*) { } template void f0(int, float*); template void f0<>(double, float*); + +template struct hash { }; +struct S { + bool operator==(const S&) const { return false; } +}; + +template struct Hash_map { + void Method(const T& x) { h(x); } + hash h; +}; + +Hash_map *x; +const Hash_map *foo() { + return x; +} + +template<> struct hash { + int operator()(const S& k) const { + return 0; + } +};