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 | cb1c77f90d4e747b83a0d0cc125dc01567378f82 (patch) | |
tree | 2e43194240fe7d8f7477350b525a277af0b27a6d | |
parent | f75b8309e3e40290683e3d34bac3a04e88d9c625 (diff) |
support the warn_unused_result in C++ class methods
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92095 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AST/Expr.cpp | 2 | ||||
-rw-r--r-- | test/SemaCXX/warn-unused-variables.cpp | 11 |
2 files changed, 13 insertions, 0 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index cb0165c8df..960d83d103 100644 --- a/lib/AST/Expr.cpp +++ b/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/test/SemaCXX/warn-unused-variables.cpp b/test/SemaCXX/warn-unused-variables.cpp index 83a61bf8e0..5620248f50 100644 --- a/test/SemaCXX/warn-unused-variables.cpp +++ b/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}} +} |