111
|
1 /* { dg-do link } */
|
|
2 /* { dg-options "--param allow-store-data-races=0" } */
|
|
3 /* { dg-final { simulate-thread } } */
|
|
4
|
|
5 #include <stdio.h>
|
|
6 #include <stdlib.h>
|
|
7 #include "../../gcc.dg/simulate-thread/simulate-thread.h"
|
|
8
|
|
9 struct bits
|
|
10 {
|
|
11 char a;
|
|
12 int b:7;
|
|
13 int c:9;
|
|
14 unsigned char d;
|
|
15 } *p;
|
|
16
|
|
17 static int global = 0;
|
|
18
|
|
19 void simulate_thread_other_threads()
|
|
20 {
|
|
21 global++;
|
|
22 p->d = global % 256;
|
|
23 }
|
|
24
|
|
25 int simulate_thread_step_verify()
|
|
26 {
|
|
27 if (p->d != global % 256)
|
|
28 {
|
|
29 printf("FAIL: invalid intermediate result\n");
|
|
30 return 1;
|
|
31 }
|
|
32 return 0;
|
|
33 }
|
|
34
|
|
35 int simulate_thread_final_verify()
|
|
36 {
|
|
37 if (p->c != 55)
|
|
38 {
|
|
39 printf("FAIL: invalid final result\n");
|
|
40 return 1;
|
|
41 }
|
|
42 return 0;
|
|
43 }
|
|
44
|
|
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()
|
|
49 {
|
|
50 p -> c = 55;
|
|
51 }
|
|
52
|
|
53
|
|
54 int main()
|
|
55 {
|
|
56 p = (struct bits *) calloc (1, sizeof (struct bits));
|
|
57 simulate_thread_main();
|
|
58 simulate_thread_done();
|
|
59 return 0;
|
|
60 }
|