[cfe-commits] r94173 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/SemaCXX/virtual-override.cpp

Chandler Carruth chandlerc at gmail.com
Fri Jan 22 05:07:42 PST 2010


Author: chandlerc
Date: Fri Jan 22 07:07:41 2010
New Revision: 94173

URL: http://llvm.org/viewvc/llvm-project?rev=94173&view=rev
Log:
Fix an obvious goof that caused us to only see the top level of return types
when checking for covariance. Added some fun test cases, fixes PR6110.

This felt obvious enough to just commit. ;] Let me know if anything needs
tweaking.

Modified:
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/test/SemaCXX/virtual-override.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=94173&r1=94172&r2=94173&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Jan 22 07:07:41 2010
@@ -5622,13 +5622,13 @@
   QualType NewClassTy, OldClassTy;
 
   /// Both types must be pointers or references to classes.
-  if (PointerType *NewPT = dyn_cast<PointerType>(NewTy)) {
-    if (PointerType *OldPT = dyn_cast<PointerType>(OldTy)) {
+  if (PointerType *NewPT = dyn_cast<PointerType>(CNewTy)) {
+    if (PointerType *OldPT = dyn_cast<PointerType>(COldTy)) {
       NewClassTy = NewPT->getPointeeType();
       OldClassTy = OldPT->getPointeeType();
     }
-  } else if (ReferenceType *NewRT = dyn_cast<ReferenceType>(NewTy)) {
-    if (ReferenceType *OldRT = dyn_cast<ReferenceType>(OldTy)) {
+  } else if (ReferenceType *NewRT = dyn_cast<ReferenceType>(CNewTy)) {
+    if (ReferenceType *OldRT = dyn_cast<ReferenceType>(COldTy)) {
       NewClassTy = NewRT->getPointeeType();
       OldClassTy = OldRT->getPointeeType();
     }

Modified: cfe/trunk/test/SemaCXX/virtual-override.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/virtual-override.cpp?rev=94173&r1=94172&r2=94173&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/virtual-override.cpp (original)
+++ cfe/trunk/test/SemaCXX/virtual-override.cpp Fri Jan 22 07:07:41 2010
@@ -197,3 +197,20 @@
     virtual Derived<int>* Method();
   };
 }
+
+// Look through template types and typedefs to see whether return types are
+// pointers or references.
+namespace PR6110 {
+  class Base {};
+  class Derived : public Base {};
+
+  typedef Base* BaseP;
+  typedef Derived* DerivedP;
+
+  class X { virtual BaseP f(); };
+  class X1 : public X { virtual DerivedP f(); };
+
+  template <typename T> class Y { virtual T f(); };
+  template <typename T1, typename T> class Y1 : public Y<T> { virtual T1 f(); };
+  Y1<Derived*, Base*> y;
+}





More information about the cfe-commits mailing list