aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/obj-c++.dg/property/dotsyntax-11.mm
blob: 6c9d924ca82ae32a05539bd9376ff9794324add1 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
/* { dg-do compile } */

/* Test the error reporting for the dot-syntax in the scenario where
   we have a setter, but not a getter, yet a getter is requested.  */

#include <stdlib.h>
#include <objc/objc.h>
#include <objc/runtime.h>

static int c;

@interface MyRootClass
{
  Class isa;
  int a;
}
+ (id) initialize;
+ (id) alloc;
- (id) init;
- (void) setCount: (int)count;
+ (void) setClassCount: (int)count;
@end

@implementation MyRootClass
+ (id) initialize { return self; }
+ (id) alloc { return class_createInstance (self, 0); }
- (id) init { return self; }
- (void) setCount: (int)count
{
  a = count;
}
+ (void) setClassCount: (int)count
{
  c = count;
}
@end

@interface MySubClass : MyRootClass
+ (int) testMe;
- (int) testMe;
@end

@implementation MySubClass
- (int) testMe
{
  super.count = 400;
  if (super.count != 400) /* { dg-error "no .count. getter found" } */
    abort ();             

  return super.count;     /* { dg-error "no .count. getter found" } */
}
+ (int) testMe
{
  super.classCount = 4000;
  if (super.classCount != 4000) /* { dg-error "no .classCount. getter found" } */
    abort ();

  return super.classCount;      /* { dg-error "no .classCount. getter found" } */
}
@end