1// RUN: %clang_cc1 %s -verify -Wunused -Wunused-parameter -fsyntax-only 2 3int printf(const char *, ...); 4 5@interface Greeter 6+ (void) hello; 7@end 8 9@implementation Greeter 10+ (void) hello { printf("Hello, World!\n"); } 11@end 12 13int test1(void) { 14 [Greeter hello]; 15 return 0; 16} 17 18@interface NSObject @end 19@interface NSString : NSObject 20- (int)length; 21@end 22 23void test2() { 24 @"pointless example call for test purposes".length; // expected-warning {{property access result unused - getters should not be used for side effects}} 25} 26 27@interface foo 28- (int)meth: (int)x: (int)y: (int)z ; 29@end 30 31@implementation foo 32- (int) meth: (int)x: 33(int)y: // expected-warning{{unused}} 34(int) __attribute__((unused))z { return x; } 35@end 36 37//===------------------------------------------------------------------------=== 38// The next test shows how clang accepted attribute((unused)) on ObjC 39// instance variables, which GCC does not. 40//===------------------------------------------------------------------------=== 41 42#if __has_feature(attribute_objc_ivar_unused) 43#define UNUSED_IVAR __attribute__((unused)) 44#else 45#error __attribute__((unused)) not supported on ivars 46#endif 47 48@interface TestUnusedIvar { 49 id y __attribute__((unused)); // no-warning 50 id x UNUSED_IVAR; // no-warning 51} 52@end 53 54