1 // PR c++/33894 2 // { dg-do run } 3 // { dg-options "-O2" } 4 5 extern "C" void abort (); 6 7 int check; 8 9 template<typename T> void foo()10foo () 11 { 12 #pragma omp atomic 13 check |= sizeof (T); 14 } 15 16 template<typename T> void bar(T * x,T y)17bar (T *x, T y) 18 { 19 #pragma omp atomic 20 *x += y; 21 } 22 23 template<typename T> void baz()24baz () 25 { 26 #pragma omp atomic 27 check++; 28 } 29 30 int main()31main () 32 { 33 int i = 0; 34 long l = 0; 35 36 check = 0; 37 foo<char> (); 38 if (check != sizeof (char)) 39 abort (); 40 foo<short> (); 41 if (check != (sizeof (char) | sizeof (short))) 42 abort (); 43 bar(&i, 4); 44 bar(&l, 8L); 45 if (i != 4 || l != 8L) 46 abort (); 47 baz<char> (); 48 if (check != (sizeof (char) | sizeof (short)) + 1) 49 abort (); 50 baz<long double> (); 51 if (check != (sizeof (char) | sizeof (short)) + 2) 52 abort (); 53 } 54