]> granicus.if.org Git - clang/commitdiff
Clang really intends to reject attribute 'warn_unused_result' on Objective-C methods...
authorTed Kremenek <kremenek@apple.com>
Sun, 21 Feb 2010 05:15:32 +0000 (05:15 +0000)
committerTed Kremenek <kremenek@apple.com>
Sun, 21 Feb 2010 05:15:32 +0000 (05:15 +0000)
instead it crashes on them.  We might extend this attribute to work on methods, but for
now fix the crasher.  Addresses <rdar://problem/7670939>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96723 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclAttr.cpp
test/SemaObjC/method-warn-unused-attribute.m [new file with mode: 0644]

index ef82d53b5c7841c8b1e36aa15078ea57e34c6d91..8178a147513bfe525e5887dec441b082ddf33aa2 100644 (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;
diff --git a/test/SemaObjC/method-warn-unused-attribute.m b/test/SemaObjC/method-warn-unused-attribute.m
new file mode 100644 (file)
index 0000000..d9dcf99
--- /dev/null
@@ -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
+
+