summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/volatile-bitfields-1.c
blob: 6adda27fea4c07beae39b36789bd675064d8963d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* { dg-options "-fstrict-volatile-bitfields" } */
/* { dg-do run } */

extern int puts(const char *);
extern void abort(void) __attribute__((noreturn));

typedef struct {
  volatile unsigned short a:8, b:8;
} BitStruct;

BitStruct bits = {1, 2};

void check(int i, int j)
{
  if (i != 1 || j != 2) puts("FAIL"), abort();
}

int main ()
{
  check(bits.a, bits.b);

  return 0;
}