diff options
Diffstat (limited to 'gcc/testsuite/obj-c++.dg/set-not-used-1.mm')
-rw-r--r-- | gcc/testsuite/obj-c++.dg/set-not-used-1.mm | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/gcc/testsuite/obj-c++.dg/set-not-used-1.mm b/gcc/testsuite/obj-c++.dg/set-not-used-1.mm new file mode 100644 index 000000000..6380ec9df --- /dev/null +++ b/gcc/testsuite/obj-c++.dg/set-not-used-1.mm @@ -0,0 +1,36 @@ + +/* { dg-do compile } */ +/* { dg-options "-Wunused-but-set-variable" } */ + +#import "../objc-obj-c++-shared/Object1.h" +#include <objc/objc-api.h> + +@interface obj : Object +{ + int value; +} +- (int) value; +- (void) setValue: (int)number; +@end + +@implementation obj : Object + +- (int) value { return value; } +- (void) setValue: (int)number { value = number; } + +@end + +int main (void) +{ + obj *a; /* { dg-bogus "set but not used" } */ + obj *b; /* { dg-bogus "set but not used" } */ + obj *c; /* { dg-warning "set but not used" } */ + + a = [obj new]; + b = [obj new]; + c = [obj new]; + + [b setValue: [a value]]; + + return [a value]; +} |