Clang really intends to reject attribute 'warn_unused_result' on Objective-C methods, but

instead it crashes on them.  We might extend this attribute to work on methods, but for
now fix the crasher.  Addresses <rdar://problem/7670939>.

llvm-svn: 96723
This commit is contained in:
Ted Kremenek 2010-02-21 05:15:32 +00:00
parent 1979007ca8
commit 2fb89539f7
2 changed files with 9 additions and 1 deletions

View File

@ -754,7 +754,7 @@ static void HandleWarnUnusedResult(Decl *D, const AttributeList &Attr, Sema &S)
return;
}
if (!isFunctionOrMethod(D)) {
if (!isFunction(D)) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
<< Attr.getName() << 0 /*function*/;
return;

View File

@ -0,0 +1,8 @@
// RUN: %clang_cc1 -fsyntax-only -Wunused-value -verify %s
@interface INTF
// Currently this is rejected by both GCC and Clang (and Clang was crashing on it).
- (id) foo __attribute__((warn_unused_result)); // expected-warning{{warning: 'warn_unused_result' attribute only applies to function types}}
@end