[cfe-commits] r81507 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaCXX/attr-deprecated.cpp

Anders Carlsson andersca at mac.com
Thu Sep 10 22:54:14 PDT 2009


Author: andersca
Date: Fri Sep 11 00:54:14 2009
New Revision: 81507

URL: http://llvm.org/viewvc/llvm-project?rev=81507&view=rev
Log:
Fix PR4878 for real.

Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/SemaCXX/attr-deprecated.cpp

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Sep 11 00:54:14 2009
@@ -1002,7 +1002,16 @@
           MarkDeclarationReferenced(Loc, D);
           if (PerformObjectMemberConversion(This, D))
             return ExprError();
-          if (DiagnoseUseOfDecl(D, Loc))
+          
+          bool ShouldCheckUse = true;
+          if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(D)) {
+            // Don't diagnose the use of a virtual member function unless it's
+            // explicitly qualified.
+            if (MD->isVirtual() && (!SS || !SS->isSet()))
+              ShouldCheckUse = false;
+          }
+          
+          if (ShouldCheckUse && DiagnoseUseOfDecl(D, Loc))
             return ExprError();
           return Owned(BuildMemberExpr(Context, This, true, SS, D,
                                        Loc, MemberType));

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

==============================================================================
--- cfe/trunk/test/SemaCXX/attr-deprecated.cpp (original)
+++ cfe/trunk/test/SemaCXX/attr-deprecated.cpp Fri Sep 11 00:54:14 2009
@@ -27,12 +27,25 @@
 
 struct B {
   virtual void f() __attribute__((deprecated));
+  void g();
 };
 
+void B::g() {
+  f();
+  B::f(); // expected-warning{{'f' is deprecated}}
+}
+
 struct C : B {
   virtual void f();
+  void g();
 };
 
+void C::g() {
+  f();
+  C::f();
+  B::f(); // expected-warning{{'f' is deprecated}}
+}
+
 void f(B* b, C *c) {
   b->f();
   b->B::f(); // expected-warning{{'f' is deprecated}}





More information about the cfe-commits mailing list