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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [objc.dg/] [bitfield-1.m] - Blame information for rev 867

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

Line No. Rev Author Line
1 149 jeremybenn
/* Check if bitfield ivars are inherited correctly (i.e., without
2
   being "promoted" to ints).  */
3
/* Contributed by Ziemowit Laski <zlaski@apple.com>.  */
4
/* { dg-do run } */
5
 
6
#include <objc/objc.h>
7
#include <objc/Object.h>
8
 
9
extern void abort(void);
10
 
11
#define CHECK_IF(expr) if(!(expr)) abort();
12
 
13
@interface Base: Object
14
{
15
    int full;
16
    int full2: 32;
17
    int _refs: 8;
18
    int field2: 3;
19
    unsigned f3: 8;
20
    short cc;
21
    unsigned g: 16;
22
    int r2: 8;
23
    int r3: 8;
24
    int r4: 2;
25
    int r5: 8;
26
    char c;
27
}
28
- (void)setValues;
29
@end
30
 
31
@interface Derived: Base
32
{
33
    char d;
34
    int _field3: 6;
35
}
36
- (void)checkValues;
37
@end
38
 
39
@implementation Base
40
-(void)setValues {
41
  full = 1;
42
  full2 = 2;
43
  _refs = 3;
44
  field2 = 1;
45
  f3 = 6;
46
  cc = 7;
47
  g = 8;
48
  r2 = 9;
49
  r3 = 10;
50
  r4 = 1;
51
  r5 = 12;
52
  c = 13;
53
}
54
@end
55
 
56
@implementation Derived
57
-(void)checkValues {
58
  CHECK_IF(full == 1);
59
  CHECK_IF(full2 == 2);
60
  CHECK_IF(_refs == 3);
61
  CHECK_IF(field2 == 1);
62
  CHECK_IF(f3 == 6);
63
  CHECK_IF(cc == 7);
64
  CHECK_IF(g == 8);
65
  CHECK_IF(r2 == 9);
66
  CHECK_IF(r3 == 10);
67
  CHECK_IF(r4 == 1);
68
  CHECK_IF(r5 == 12);
69
  CHECK_IF(c == 13);
70
}
71
@end
72
 
73
int main(void) {
74
  Derived *obj = [[Derived alloc] init];
75
 
76
  [obj setValues];
77
  [obj checkValues];
78
 
79
  return 0;
80
}

powered by: WebSVN 2.1.0

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