[cfe-commits] r92095 - in /cfe/trunk: lib/AST/Expr.cpp test/SemaCXX/warn-unused-variables.cpp
Nuno Lopes
nunoplopes at sapo.pt
Wed Dec 23 16:28:18 PST 2009
Author: nlopes
Date: Wed Dec 23 18:28:18 2009
New Revision: 92095
URL: http://llvm.org/viewvc/llvm-project?rev=92095&view=rev
Log:
support the warn_unused_result in C++ class methods
Modified:
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/test/SemaCXX/warn-unused-variables.cpp
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=92095&r1=92094&r2=92095&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Wed Dec 23 18:28:18 2009
@@ -402,6 +402,8 @@
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;
}
Modified: cfe/trunk/test/SemaCXX/warn-unused-variables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unused-variables.cpp?rev=92095&r1=92094&r2=92095&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-unused-variables.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-unused-variables.cpp Wed Dec 23 18:28:18 2009
@@ -32,3 +32,14 @@
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}}
+}
More information about the cfe-commits
mailing list