support the warn_unused_result in C++ class methods

llvm-svn: 92095
This commit is contained in:
Nuno Lopes 2009-12-24 00:28:18 +00:00
parent 8bc072cda6
commit c095b5361a
2 changed files with 13 additions and 0 deletions

View File

@ -402,6 +402,8 @@ Decl *CallExpr::getCalleeDecl() {
Expr *CEE = getCallee()->IgnoreParenCasts();
if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(CEE))
return DRE->getDecl();
if (MemberExpr *ME = dyn_cast<MemberExpr>(CEE))
return ME->getMemberDecl();
return 0;
}

View File

@ -32,3 +32,14 @@ namespace PR5531 {
C();
}
}
struct X {
int foo() __attribute__((warn_unused_result));
};
void bah() {
X x, *x2;
x.foo(); // expected-warning {{ignoring return value of function declared with warn_unused_result attribute}}
x2->foo(); // expected-warning {{ignoring return value of function declared with warn_unused_result attribute}}
}