[cfe-commits] r96723 - in /cfe/trunk: lib/Sema/SemaDeclAttr.cpp test/SemaObjC/method-warn-unused-attribute.m
Ted Kremenek
kremenek at apple.com
Sat Feb 20 21:15:32 PST 2010
Author: kremenek
Date: Sat Feb 20 23:15:32 2010
New Revision: 96723
URL: http://llvm.org/viewvc/llvm-project?rev=96723&view=rev
Log:
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>.
Added:
cfe/trunk/test/SemaObjC/method-warn-unused-attribute.m
Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=96723&r1=96722&r2=96723&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Sat Feb 20 23:15:32 2010
@@ -754,7 +754,7 @@
return;
}
- if (!isFunctionOrMethod(D)) {
+ if (!isFunction(D)) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
<< Attr.getName() << 0 /*function*/;
return;
Added: cfe/trunk/test/SemaObjC/method-warn-unused-attribute.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/method-warn-unused-attribute.m?rev=96723&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/method-warn-unused-attribute.m (added)
+++ cfe/trunk/test/SemaObjC/method-warn-unused-attribute.m Sat Feb 20 23:15:32 2010
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunused-value -verify %s
+
+ at 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}}
+ at end
+
+
More information about the cfe-commits
mailing list