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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [objc.dg/] [bitfield-5.m] - Blame information for rev 707

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

Line No. Rev Author Line
1 704 jeremybenn
/* Check ObjC class layout follows the ABI (informally)
2
   set in the past.  ObjC structs must be laid out as if
3
   all ivars, including those inherited from superclasses,
4
   were defined at once (i.e., any padding introduced for
5
   superclasses should be removed).  */
6
/* Contributed by Ziemowit Laski <zlaski@apple.com>.  */
7
/* { dg-options "-Wpadded" } */
8
/* { dg-do run } */
9
 
10
#include "../objc-obj-c++-shared/TestsuiteObject.m"
11
#include <objc/objc.h>
12
#include <stdlib.h>
13
 
14
#define CHECK_IF(expr) if(!(expr)) abort()
15
 
16
enum Enum { zero, one, two, three, four };
17
 
18
@interface Base: TestsuiteObject {
19
@public
20
  unsigned a: 2;
21
  int b: 3;
22
  enum Enum c: 4;
23
  unsigned d: 5;
24
} /* { dg-warning "padding struct size to alignment boundary" } */
25
@end
26
 
27
struct Base_0 {
28
  Class isa;
29
  unsigned a: 2;
30
  int b: 3;
31
  enum Enum c: 4;
32
  unsigned d: 5;
33
}; /* { dg-warning "padding struct size to alignment boundary" } */
34
 
35
@interface Derived: Base {
36
@public
37
  signed e: 5;
38
  unsigned f: 4;
39
  enum Enum g: 3;
40
} /* { dg-warning "padding struct size to alignment boundary" } */
41
@end
42
 
43
struct Derived_0 {
44
  Class isa;
45
  unsigned a: 2;
46
  int b: 3;
47
  enum Enum c: 4;
48
  unsigned d: 5;
49
  signed e: 5;
50
  int f: 4;
51
  enum Enum g: 3;
52
}; /* { dg-warning "padding struct size to alignment boundary" } */
53
 
54
@interface Leaf: Derived {
55
@public
56
  signed h: 2;
57
} /* { dg-warning "padding struct size to alignment boundary" } */
58
@end
59
 
60
struct Leaf_0 {
61
  Class isa;
62
  unsigned a: 2;
63
  int b: 3;
64
  enum Enum c: 4;
65
  unsigned d: 5;
66
  signed e: 5;
67
  unsigned f: 4;
68
  enum Enum g: 3;
69
  signed h: 2;
70
}; /* { dg-warning "padding struct size to alignment boundary" } */
71
 
72
/* Note that the semicolon after @defs(...) is optional.  */
73
 
74
typedef struct { @defs(Base) } Base_t;  /* { dg-warning "padding struct size to alignment boundary" } */
75
typedef struct { @defs(Derived); } Derived_t;  /* { dg-warning "padding struct size to alignment boundary" } */
76
typedef struct { @defs(Leaf); } Leaf_t;  /* { dg-warning "padding struct size to alignment boundary" } */
77
 
78
int main(void)
79
{
80
  struct Leaf_0 l_0;
81
  Leaf *l = (Leaf *)&l_0;
82
  Leaf_t *l_t = (Leaf_t *)&l_0;
83
 
84
  CHECK_IF(sizeof(Base_t) == sizeof(Base));
85
  CHECK_IF(sizeof(Derived_t) == sizeof(Derived));
86
  CHECK_IF(sizeof(Leaf_t) == sizeof(Leaf));
87
 
88
  CHECK_IF(sizeof(struct Base_0) == sizeof(Base));
89
  CHECK_IF(sizeof(struct Derived_0) == sizeof(Derived));
90
  CHECK_IF(sizeof(struct Leaf_0) == sizeof(Leaf));
91
 
92
  l_0.isa = (Class)0;
93
  l_0.a = 3;
94
  l_0.b = 0;
95
  l_0.c = three;
96
  l_0.d = 31;
97
  l_0.e = 0;
98
  l_0.f = 15;
99
  l_0.g = zero;
100
  l_0.h = -2;
101
 
102
  CHECK_IF(!l_t->isa);
103
  CHECK_IF(l->a == 3 && l_t->a == 3);
104
  CHECK_IF(!l->b && !l_t->b);
105
  CHECK_IF(l->c == three && l_t->c == three);
106
  CHECK_IF(l->d == 31 && l_t->d == 31);
107
  CHECK_IF(!l->e && !l_t->e);
108
  CHECK_IF(l->f == 15 && l_t->f == 15);
109
  CHECK_IF(l->g == zero && l_t->g == zero);
110
  CHECK_IF(l->h == -2 && l_t->h == -2);
111
 
112
  return 0;
113
}

powered by: WebSVN 2.1.0

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