xref: /openbsd-src/gnu/gcc/libgomp/testsuite/libgomp.c++/copyin-2.C (revision 404b540a9034ac75a6199ad1a32d1bbc7a0d4210)
1*404b540aSrobert // { dg-do run }
2*404b540aSrobert // { dg-require-effective-target tls_runtime }
3*404b540aSrobert 
4*404b540aSrobert #include <omp.h>
5*404b540aSrobert 
6*404b540aSrobert extern "C" void abort (void);
7*404b540aSrobert 
8*404b540aSrobert struct S { int t; char buf[64]; } thr = { 32, "" };
9*404b540aSrobert #pragma omp threadprivate (thr)
10*404b540aSrobert 
11*404b540aSrobert int
main(void)12*404b540aSrobert main (void)
13*404b540aSrobert {
14*404b540aSrobert   int l = 0;
15*404b540aSrobert 
16*404b540aSrobert   omp_set_dynamic (0);
17*404b540aSrobert   omp_set_num_threads (6);
18*404b540aSrobert 
19*404b540aSrobert #pragma omp parallel copyin (thr) reduction (||:l)
20*404b540aSrobert   {
21*404b540aSrobert     l = thr.t != 32;
22*404b540aSrobert     thr.t = omp_get_thread_num () + 11;
23*404b540aSrobert   }
24*404b540aSrobert 
25*404b540aSrobert   if (l || thr.t != 11)
26*404b540aSrobert     abort ();
27*404b540aSrobert 
28*404b540aSrobert #pragma omp parallel reduction (||:l)
29*404b540aSrobert   l = thr.t != omp_get_thread_num () + 11;
30*404b540aSrobert 
31*404b540aSrobert   if (l)
32*404b540aSrobert     abort ();
33*404b540aSrobert   return 0;
34*404b540aSrobert }
35