testsuite/libgomp.c++/atomic-1.C

Go to the documentation of this file.
00001 // PR c++/33894
00002 // { dg-do run }
00003 // { dg-options "-O2" }
00004 
00005 extern "C" void abort ();
00006 
00007 int check;
00008 
00009 template<typename T> void
00010 foo ()
00011 {
00012   #pragma omp atomic
00013   check |= sizeof (T);
00014 }
00015 
00016 template<typename T> void
00017 bar (T *x, T y)
00018 {
00019   #pragma omp atomic
00020   *x += y;
00021 }
00022 
00023 template<typename T> void
00024 baz ()
00025 {
00026   #pragma omp atomic
00027   check++;
00028 }
00029 
00030 int
00031 main ()
00032 {
00033   int i = 0;
00034   long l = 0;
00035 
00036   check = 0;
00037   foo<char> ();
00038   if (check != sizeof (char))
00039     abort ();
00040   foo<short> ();
00041   if (check != (sizeof (char) | sizeof (short)))
00042     abort ();
00043   bar(&i, 4);
00044   bar(&l, 8L);
00045   if (i != 4 || l != 8L)
00046     abort ();
00047   baz<char> ();
00048   if (check != (sizeof (char) | sizeof (short)) + 1)
00049     abort ();
00050   baz<long double> ();
00051   if (check != (sizeof (char) | sizeof (short)) + 2)
00052     abort ();
00053 }

Generated on Fri Apr 5 05:38:10 2013 for Libgomp by  doxygen 1.4.7