analyzer: enable taint state machine by default [PR103533]
[official-gcc.git] / gcc / testsuite / c-c++-common / simulate-thread / bitfields-4.c
blob84aad5e9e216f2672bd8685df729d3029e023cab
1 /* { dg-do link } */
2 /* { dg-options "-fno-allow-store-data-races" } */
3 /* { dg-final { simulate-thread } } */
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include "../../gcc.dg/simulate-thread/simulate-thread.h"
9 struct bits
11 char a;
12 int b:7;
13 int c:9;
14 unsigned char d;
15 } *p;
17 static int global = 0;
19 void simulate_thread_other_threads()
21 global++;
22 p->d = global % 256;
25 int simulate_thread_step_verify()
27 if (p->d != global % 256)
29 printf("FAIL: invalid intermediate result\n");
30 return 1;
32 return 0;
35 int simulate_thread_final_verify()
37 if (p->c != 55)
39 printf("FAIL: invalid final result\n");
40 return 1;
42 return 0;
45 /* Store into <c> should not clobber <d>. */
46 /* We should not use a 32-bit move to store into p->, but a smaller move. */
47 __attribute__((noinline))
48 void simulate_thread_main()
50 p -> c = 55;
54 int main()
56 p = (struct bits *) calloc (1, sizeof (struct bits));
57 simulate_thread_main();
58 simulate_thread_done();
59 return 0;