aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/AST/Expr.cpp2
-rw-r--r--test/SemaCXX/warn-unused-variables.cpp11
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}}
+}