[cfe-commits] r113722 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/SemaCXX/conversion-function.cpp
Douglas Gregor
dgregor at apple.com
Sun Sep 12 00:22:28 PDT 2010
Author: dgregor
Date: Sun Sep 12 02:22:28 2010
New Revision: 113722
URL: http://llvm.org/viewvc/llvm-project?rev=113722&view=rev
Log:
Don't complain about useless user-defined conversion functions when
they were instantiated from a template. In template metaprogramming,
stuff happens. Fixes PR8065.
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/conversion-function.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=113722&r1=113721&r2=113722&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sun Sep 12 02:22:28 2010
@@ -3233,7 +3233,10 @@
= 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)
Modified: cfe/trunk/test/SemaCXX/conversion-function.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/conversion-function.cpp?rev=113722&r1=113721&r2=113722&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/conversion-function.cpp (original)
+++ cfe/trunk/test/SemaCXX/conversion-function.cpp Sun Sep 12 02:22:28 2010
@@ -325,3 +325,21 @@
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;
+}
More information about the cfe-commits
mailing list