1 /* { dg-do run } */ 2 3 extern void abort (void); 4 _Bool v, x1, x2, x3, x4, x5, x6; 5 6 void foo(void)7foo (void) 8 { 9 #pragma omp atomic capture 10 v = ++x1; 11 if (!v) 12 abort (); 13 #pragma omp atomic capture 14 v = x2++; 15 if (v) 16 abort (); 17 #pragma omp atomic capture 18 v = --x3; 19 if (v) 20 abort (); 21 #pragma omp atomic capture 22 v = x4--; 23 if (!v) 24 abort (); 25 #pragma omp atomic capture 26 { v = x5; x5 |= 1; } 27 if (v) 28 abort (); 29 #pragma omp atomic capture 30 { x6 |= 1; v = x6; } 31 if (!v) 32 abort (); 33 } 34 35 void bar(void)36bar (void) 37 { 38 #pragma omp atomic write 39 x1 = 0; 40 #pragma omp atomic write 41 x2 = 0; 42 #pragma omp atomic write 43 x3 = 1; 44 #pragma omp atomic write 45 x4 = 1; 46 #pragma omp atomic capture 47 { ++x1; v = x1; } 48 if (!v) 49 abort (); 50 #pragma omp atomic capture 51 { v = x2; x2++; } 52 if (v) 53 abort (); 54 #pragma omp atomic capture 55 { --x3; v = x3; } 56 if (v) 57 abort (); 58 #pragma omp atomic capture 59 { v = x4; x4--; } 60 if (!v) 61 abort (); 62 #pragma omp atomic write 63 x1 = 0; 64 #pragma omp atomic write 65 x2 = 0; 66 #pragma omp atomic write 67 x3 = 1; 68 #pragma omp atomic write 69 x4 = 1; 70 #pragma omp atomic capture 71 { x1++; v = x1; } 72 if (!v) 73 abort (); 74 #pragma omp atomic capture 75 { v = x2; ++x2; } 76 if (v) 77 abort (); 78 #pragma omp atomic capture 79 { x3--; v = x3; } 80 if (v) 81 abort (); 82 #pragma omp atomic capture 83 { v = x4; --x4; } 84 if (!v) 85 abort (); 86 } 87 88 int main()89main () 90 { 91 #pragma omp atomic write 92 x3 = 1; 93 #pragma omp atomic write 94 x4 = 1; 95 foo (); 96 bar (); 97 return 0; 98 } 99