summaryrefslogtreecommitdiff
path: root/gcc/testsuite/objc.dg/set-not-used-1.m
blob: 6380ec9df5d007ab34e6a63087c5cb9e96a6d736 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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];
}