OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [obj-c++.dg/] [property/] [dotsyntax-17.mm] - Blame information for rev 717

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 703 jeremybenn
/* Contributed by Nicola Pero , November 2010.  */
2
/* { dg-do compile } */
3
 
4
/* Test errors with the dot-syntax with pre/post increment and decrement.  */
5
 
6
#include 
7
#include 
8
#include 
9
 
10
@interface MyRootClass
11
{
12
  Class isa;
13
  int count;
14
  int a;
15
}
16
+ (id) initialize;
17
+ (id) alloc;
18
- (id) init;
19
@property (assign, readonly) int count;
20
- (void) setWriteOnlyCount: (int)value;
21
@end
22
 
23
@implementation MyRootClass
24
+ (id) initialize { return self; }
25
+ (id) alloc { return class_createInstance (self, 0); }
26
- (id) init { return self; }
27
@synthesize count;
28
- (void) setWriteOnlyCount: (int)value
29
{
30
  a = value;
31
}
32
@end
33
 
34
int main (void)
35
{
36
  MyRootClass *object = [[MyRootClass alloc] init];
37
 
38
  object.count = 10; /* { dg-error "readonly property can not be set" } */
39
  if (object.count != 10) /* Ok */
40
    abort ();
41
 
42
  /* Test errors when trying to change a readonly property using
43
     pre/post increment/decrement operators.  */
44
  object.count++; /* { dg-error "readonly property can not be set" } */
45
 
46
  ++object.count; /* { dg-error "readonly property can not be set" } */
47
 
48
  object.count--; /* { dg-error "readonly property can not be set" } */
49
 
50
  --object.count; /* { dg-error "readonly property can not be set" } */
51
 
52
  /* Test errors when trying to change something using Objective-C 2.0
53
     dot-syntax but there is a setter but no getter.  */
54
  object.writeOnlyCount = 10; /* Ok */
55
 
56
  object.writeOnlyCount++; /* { dg-error "no .writeOnlyCount. getter found" } */
57
 
58
  ++object.writeOnlyCount; /* { dg-error "no .writeOnlyCount. getter found" } */
59
 
60
  object.writeOnlyCount--; /* { dg-error "no .writeOnlyCount. getter found" } */
61
 
62
  --object.writeOnlyCount; /* { dg-error "no .writeOnlyCount. getter found" } */
63
 
64
  return 0;
65
}
66
 
67
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.