diff options
| author | Nuno Lopes <nunoplopes@sapo.pt> | 2009-12-24 00:28:18 +0000 |
|---|---|---|
| committer | Nuno Lopes <nunoplopes@sapo.pt> | 2009-12-24 00:28:18 +0000 |
| commit | c095b5361a5a8d949f42a5f6ce50b80254e88396 (patch) | |
| tree | 416d1947290369297f8c02a0df3db389c945c008 | |
| parent | 8bc072cda6adeca730991f9e0c88c93c7e67597c (diff) | |
| download | bcm5719-llvm-c095b5361a5a8d949f42a5f6ce50b80254e88396.tar.gz bcm5719-llvm-c095b5361a5a8d949f42a5f6ce50b80254e88396.zip | |
support the warn_unused_result in C++ class methods
llvm-svn: 92095
| -rw-r--r-- | clang/lib/AST/Expr.cpp | 2 | ||||
| -rw-r--r-- | clang/test/SemaCXX/warn-unused-variables.cpp | 11 |
2 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index cb0165c8df7..960d83d103a 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -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; } diff --git a/clang/test/SemaCXX/warn-unused-variables.cpp b/clang/test/SemaCXX/warn-unused-variables.cpp index 83a61bf8e00..5620248f500 100644 --- a/clang/test/SemaCXX/warn-unused-variables.cpp +++ b/clang/test/SemaCXX/warn-unused-variables.cpp @@ -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}} +} |

