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.

llvm-svn: 133907
This commit is contained in:
Chandler Carruth 2011-06-27 08:31:58 +00:00
parent c933221826
commit 5925926a2f
2 changed files with 9 additions and 1 deletions

View File

@ -9168,7 +9168,7 @@ 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)
@ -9176,6 +9176,7 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
Diag(MD->getLocStart(), diag::note_previous_decl) << MD->getDeclName();
}
}
return MaybeBindToTemporary(TheCall);
}

View 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(); };
};