[cfe-commits] r133907 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaCXX/warn-pure-virtual-call-from-ctor-dtor.cpp

Chandler Carruth chandlerc at gmail.com
Mon Jun 27 01:31:58 PDT 2011


Author: chandlerc
Date: Mon Jun 27 03:31:58 2011
New Revision: 133907

URL: http://llvm.org/viewvc/llvm-project?rev=133907&view=rev
Log:
Fix missing braces around two statements that were intended to be part
of a single if block. This is really annoying to track down and test.
Silly changes to the test case caused it to stop showing up. I wish
there were a more concrete way of asserting that a note attaches to the
intended diagnostic.

This fixes PR10195.

Modified:
    cfe/trunk/lib/Sema/SemaOverload.cpp
    cfe/trunk/test/SemaCXX/warn-pure-virtual-call-from-ctor-dtor.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=133907&r1=133906&r2=133907&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Mon Jun 27 03:31:58 2011
@@ -9168,13 +9168,14 @@
       TheCall->getMethodDecl()->isPure()) {
     const CXXMethodDecl *MD = TheCall->getMethodDecl();
 
-    if (isa<CXXThisExpr>(MemExpr->getBase()->IgnoreParenCasts()))
+    if (isa<CXXThisExpr>(MemExpr->getBase()->IgnoreParenCasts())) {
       Diag(MemExpr->getLocStart(), 
            diag::warn_call_to_pure_virtual_member_function_from_ctor_dtor)
         << MD->getDeclName() << isa<CXXDestructorDecl>(CurContext)
         << MD->getParent()->getDeclName();
 
       Diag(MD->getLocStart(), diag::note_previous_decl) << MD->getDeclName();
+    }
   }
   return MaybeBindToTemporary(TheCall);
 }

Modified: cfe/trunk/test/SemaCXX/warn-pure-virtual-call-from-ctor-dtor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-pure-virtual-call-from-ctor-dtor.cpp?rev=133907&r1=133906&r2=133907&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-pure-virtual-call-from-ctor-dtor.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-pure-virtual-call-from-ctor-dtor.cpp Mon Jun 27 03:31:58 2011
@@ -5,3 +5,10 @@
 
   virtual void f() = 0; // expected-note 2 {{'f' declared here}}
 };
+
+// Don't warn (or note) when calling the function on a pointer. (PR10195)
+struct B {
+  A *a;
+  B() { a->f(); };
+  ~B() { a->f(); };
+};





More information about the cfe-commits mailing list