xref: /openbsd-src/gnu/gcc/libgomp/testsuite/libgomp.c++/single-2.C (revision 404b540a9034ac75a6199ad1a32d1bbc7a0d4210)
1*404b540aSrobert extern "C" void abort (void);
2*404b540aSrobert 
3*404b540aSrobert struct X
4*404b540aSrobert {
5*404b540aSrobert   int a;
6*404b540aSrobert   char b;
7*404b540aSrobert   int c;
8*404b540aSrobert };
9*404b540aSrobert 
main()10*404b540aSrobert main()
11*404b540aSrobert {
12*404b540aSrobert   int i = 0;
13*404b540aSrobert   struct X x;
14*404b540aSrobert   int bad = 0;
15*404b540aSrobert 
16*404b540aSrobert   #pragma omp parallel private (i, x) shared (bad)
17*404b540aSrobert     {
18*404b540aSrobert       i = 5;
19*404b540aSrobert 
20*404b540aSrobert       #pragma omp single copyprivate (i, x)
21*404b540aSrobert 	{
22*404b540aSrobert 	  i++;
23*404b540aSrobert 	  x.a = 23;
24*404b540aSrobert 	  x.b = 42;
25*404b540aSrobert 	  x.c = 26;
26*404b540aSrobert 	}
27*404b540aSrobert 
28*404b540aSrobert       if (i != 6 || x.a != 23 || x.b != 42 || x.c != 26)
29*404b540aSrobert 	bad = 1;
30*404b540aSrobert     }
31*404b540aSrobert 
32*404b540aSrobert   if (bad)
33*404b540aSrobert     abort ();
34*404b540aSrobert 
35*404b540aSrobert   return 0;
36*404b540aSrobert }
37