[cfe-commits] r97103 - in /cfe/trunk: lib/Sema/SemaDeclAttr.cpp test/SemaObjC/unused.m
Ted Kremenek
kremenek at apple.com
Wed Feb 24 19:26:51 PST 2010
Author: kremenek
Date: Wed Feb 24 21:26:51 2010
New Revision: 97103
URL: http://llvm.org/viewvc/llvm-project?rev=97103&view=rev
Log:
Allow __attribute__((unused)) to be applied to ObjC ivars.
Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/SemaObjC/unused.m
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=97103&r1=97102&r2=97103&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed Feb 24 21:26:51 2010
@@ -521,7 +521,7 @@
return;
}
- if (!isa<VarDecl>(d) && !isFunctionOrMethod(d)) {
+ if (!isa<VarDecl>(d) && !isa<ObjCIvarDecl>(d) && !isFunctionOrMethod(d)) {
S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
<< Attr.getName() << 2 /*variable and function*/;
return;
Modified: cfe/trunk/test/SemaObjC/unused.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/unused.m?rev=97103&r1=97102&r2=97103&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/unused.m (original)
+++ cfe/trunk/test/SemaObjC/unused.m Wed Feb 24 21:26:51 2010
@@ -7,19 +7,14 @@
@end
@implementation Greeter
-+ (void) hello {
- printf("Hello, World!\n");
-}
++ (void) hello { printf("Hello, World!\n"); }
@end
-
int test1(void) {
[Greeter hello];
return 0;
}
-
-
@interface NSObject @end
@interface NSString : NSObject
- (int)length;
@@ -29,10 +24,6 @@
@"pointless example call for test purposes".length; // expected-warning {{property access result unused - getters should not have side effects}}
}
-
-
-
-
@interface foo
- (int)meth: (int)x: (int)y: (int)z ;
@end
@@ -42,3 +33,13 @@
(int)y: // expected-warning{{unused}}
(int) __attribute__((unused))z { return x; }
@end
+
+//===------------------------------------------------------------------------===
+// The next test shows how clang accepted attribute((unused)) on ObjC
+// instance variables, which GCC does not.
+//===------------------------------------------------------------------------===
+
+ at interface TestUnusedIvar {
+ id x __attribute__((unused)); // no-warning
+}
+ at end
More information about the cfe-commits
mailing list