]> granicus.if.org Git - clang/commitdiff
Fix missing braces around two statements that were intended to be part
authorChandler Carruth <chandlerc@gmail.com>
Mon, 27 Jun 2011 08:31:58 +0000 (08:31 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Mon, 27 Jun 2011 08:31:58 +0000 (08:31 +0000)
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.

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

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

index 4764ced9b468281dfd4f7af7ecc212980a7f1051..b6045123fe2189f4982e1d47ce5467c04be01325 100644 (file)
@@ -9168,13 +9168,14 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
       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);
 }
index 698eccd1d2f09b598bc4624977fe6eae3dc45846..ade6198fbd0d8363e56b722361a8d3f552b38935 100644 (file)
@@ -5,3 +5,10 @@ struct A {
 
   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(); };
+};