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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [objc.dg/] [bitfield-3.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 if the @defs() construct preserves the correct
2
   layout of bitfields.  */
3
/* Contributed by Ziemowit Laski <zlaski@apple.com>.  */
4
/* { dg-options "-Wpadded" } */
5
/* { dg-do run } */
6
 
7
#include "../objc-obj-c++-shared/TestsuiteObject.m"
8
 
9
extern void abort(void);
10
extern int strcmp(const char *str1, const char *str2);
11
#define CHECK_IF(expr) if(!(expr)) abort()
12
 
13
enum Enum { one, two, three, four };
14
 
15
@interface Base: TestsuiteObject {
16
  unsigned a: 2;
17
  int b: 3;
18
  enum Enum c: 4;
19
  unsigned d: 5;
20
} /* { dg-warning "padding struct size to alignment boundary" } */
21
@end
22
 
23
@interface Derived: Base {
24
  signed e: 5;
25
  int f: 4;
26
  enum Enum g: 3;
27
} /* { dg-warning "padding struct size to alignment boundary" } */
28
@end
29
 
30
/* Note that the semicolon after @defs(...) is optional.  */
31
 
32
typedef struct { @defs(Base) } Base_t;  /* { dg-warning "padding struct size to alignment boundary" } */
33
typedef struct { @defs(Derived); } Derived_t;  /* { dg-warning "padding struct size to alignment boundary" } */
34
 
35
int main(void)
36
{
37
  CHECK_IF(sizeof(Base_t) == sizeof(Base));
38
  CHECK_IF(sizeof(Derived_t) == sizeof(Derived));
39
 
40
#ifdef __NEXT_RUNTIME__
41
  CHECK_IF(!strcmp(@encode(Base), "{Base=#b2b3b4b5}"));
42
  CHECK_IF(!strcmp(@encode(Derived), "{Derived=#b2b3b4b5b5b4b3}"));
43
 
44
  CHECK_IF(!strcmp(@encode(Base_t), "{?=#b2b3b4b5}"));
45
  CHECK_IF(!strcmp(@encode(Derived_t), "{?=#b2b3b4b5b5b4b3}"));
46
#endif /* __NEXT_RUNTIME__ */
47
 
48
  return 0;
49
}

powered by: WebSVN 2.1.0

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