Don't complain about useless user-defined conversion functions when

they were instantiated from a template. In template metaprogramming,
stuff happens. Fixes PR8065.

llvm-svn: 113722
This commit is contained in:
Douglas Gregor 2010-09-12 07:22:28 +00:00
parent fd26915742
commit 6309e3d18e
2 changed files with 22 additions and 1 deletions

View File

@ -3233,7 +3233,10 @@ Decl *Sema::ActOnConversionDeclarator(CXXConversionDecl *Conversion) {
= Context.getCanonicalType(Context.getTypeDeclType(ClassDecl));
if (const ReferenceType *ConvTypeRef = ConvType->getAs<ReferenceType>())
ConvType = ConvTypeRef->getPointeeType();
if (ConvType->isRecordType()) {
if (Conversion->getTemplateSpecializationKind() != TSK_Undeclared &&
Conversion->getTemplateSpecializationKind() != TSK_ExplicitSpecialization)
/* Suppress disanogstics for instantiations. */;
else if (ConvType->isRecordType()) {
ConvType = Context.getCanonicalType(ConvType).getUnqualifiedType();
if (ConvType == ClassType)
Diag(Conversion->getLocation(), diag::warn_conv_to_self_not_used)

View File

@ -325,3 +325,21 @@ namespace rdar8018274 {
int i = ed;
}
}
namespace PR8065 {
template <typename T> struct Iterator;
template <typename T> struct Container;
template<>
struct Iterator<int> {
typedef Container<int> container_type;
};
template <typename T>
struct Container {
typedef typename Iterator<T>::container_type X;
operator X(void) { return X(); }
};
Container<int> test;
}