[cfe-commits] r81715 - in /cfe/trunk: include/clang/AST/DeclCXX.h test/SemaCXX/attr-deprecated.cpp

Anders Carlsson andersca at mac.com
Sun Sep 13 14:01:57 PDT 2009


Author: andersca
Date: Sun Sep 13 16:01:57 2009
New Revision: 81715

URL: http://llvm.org/viewvc/llvm-project?rev=81715&view=rev
Log:
CXXMethodDecl::isVirtual needs to check the canonical declaration. Fixes PR4878.

Modified:
    cfe/trunk/include/clang/AST/DeclCXX.h
    cfe/trunk/test/SemaCXX/attr-deprecated.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=81715&r1=81714&r2=81715&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Sun Sep 13 16:01:57 2009
@@ -776,8 +776,13 @@
   bool isInstance() const { return !isStatic(); }
 
   bool isVirtual() const {
-    return isVirtualAsWritten() ||
-      (begin_overridden_methods() != end_overridden_methods());
+    CXXMethodDecl *CD = 
+      cast<CXXMethodDecl>(const_cast<CXXMethodDecl*>(this)->getCanonicalDecl());
+
+    if (CD->isVirtualAsWritten())
+      return true;
+    
+    return (CD->begin_overridden_methods() != CD->end_overridden_methods());
   }
   
   ///

Modified: cfe/trunk/test/SemaCXX/attr-deprecated.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-deprecated.cpp?rev=81715&r1=81714&r2=81715&view=diff

==============================================================================
--- cfe/trunk/test/SemaCXX/attr-deprecated.cpp (original)
+++ cfe/trunk/test/SemaCXX/attr-deprecated.cpp Sun Sep 13 16:01:57 2009
@@ -54,3 +54,13 @@
   c->C::f();
   c->B::f(); // expected-warning{{'f' is deprecated}}
 }
+
+struct D {
+  virtual void f() __attribute__((deprecated));
+};
+
+void D::f() { }
+
+void f(D* d) {
+  d->f();
+}





More information about the cfe-commits mailing list