]> granicus.if.org Git - clang/commitdiff
Make sure we don't name a constructor or destructor with a qualified
authorDouglas Gregor <dgregor@apple.com>
Tue, 13 Jan 2009 00:11:19 +0000 (00:11 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 13 Jan 2009 00:11:19 +0000 (00:11 +0000)
type. It leads to very weird errors.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62124 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/DeclarationName.cpp
lib/Sema/SemaOverload.cpp
test/SemaCXX/overloaded-operator.cpp

index 044acd71d4828cee5889d4b347f7a437e047eddb..ae579c26fa86b377db2c945b200eeb6343775baf 100644 (file)
@@ -286,9 +286,11 @@ DeclarationNameTable::getCXXSpecialName(DeclarationName::NameKind Kind,
   switch (Kind) {
   case DeclarationName::CXXConstructorName: 
     EKind = DeclarationNameExtra::CXXConstructor;
+    assert(Ty.getCVRQualifiers() == 0 && "Constructor type must be unqualified");
     break;
   case DeclarationName::CXXDestructorName:
     EKind = DeclarationNameExtra::CXXDestructor;
+    assert(Ty.getCVRQualifiers() == 0 && "Destructor type must be unqualified");
     break;
   case DeclarationName::CXXConversionFunctionName:
     EKind = DeclarationNameExtra::CXXConversionFunction;
index 26ef1bdaa3585bbaad1f5f558bca479d835ca5ca..7ef7d85426830bf67e1499abd2691ef8e3e5b5c3 100644 (file)
@@ -1115,7 +1115,7 @@ bool Sema::IsUserDefinedConversion(Expr *From, QualType ToType,
     CXXRecordDecl *ToRecordDecl = ToRecordType->getDecl();
     DeclarationName ConstructorName 
       = Context.DeclarationNames.getCXXConstructorName(
-                                             Context.getCanonicalType(ToType));
+                        Context.getCanonicalType(ToType).getUnqualifiedType());
     DeclContext::lookup_iterator Con, ConEnd;
     for (llvm::tie(Con, ConEnd) = ToRecordDecl->lookup(ConstructorName);
          Con != ConEnd; ++Con) {
index bc473834bf75ae25225391d287d330e879b09280..d8be6bca49157db5051774904b22b096b1706024 100644 (file)
@@ -172,3 +172,14 @@ void test_arrow(Arrow1 a1, Arrow2 a2, const Arrow2 a3) {
   int &i2 = a2->m;
   a3->m; // expected-error{{no viable overloaded 'operator->'; candidate is}}
 }
+
+struct CopyConBase {
+};
+
+struct CopyCon : public CopyConBase {
+  CopyCon(const CopyConBase &Base);
+
+  CopyCon(const CopyConBase *Base) {
+    *this = *Base;
+  }
+};