xref: /openbsd-src/gnu/gcc/libgomp/testsuite/libgomp.c/appendix-a/a.29.1.c (revision 404b540a9034ac75a6199ad1a32d1bbc7a0d4210)
1*404b540aSrobert /* { dg-do run } */
2*404b540aSrobert 
3*404b540aSrobert #include <assert.h>
4*404b540aSrobert int A[2][2] = { 1, 2, 3, 4 };
5*404b540aSrobert void
f(int n,int B[n][n],int C[])6*404b540aSrobert f (int n, int B[n][n], int C[])
7*404b540aSrobert {
8*404b540aSrobert   int D[2][2] = { 1, 2, 3, 4 };
9*404b540aSrobert   int E[n][n];
10*404b540aSrobert   assert (n >= 2);
11*404b540aSrobert   E[1][1] = 4;
12*404b540aSrobert #pragma omp parallel firstprivate(B, C, D, E)
13*404b540aSrobert   {
14*404b540aSrobert     assert (sizeof (B) == sizeof (int (*)[n]));
15*404b540aSrobert     assert (sizeof (C) == sizeof (int *));
16*404b540aSrobert     assert (sizeof (D) == 4 * sizeof (int));
17*404b540aSrobert     assert (sizeof (E) == n * n * sizeof (int));
18*404b540aSrobert     /* Private B and C have values of original B and C. */
19*404b540aSrobert     assert (&B[1][1] == &A[1][1]);
20*404b540aSrobert     assert (&C[3] == &A[1][1]);
21*404b540aSrobert     assert (D[1][1] == 4);
22*404b540aSrobert     assert (E[1][1] == 4);
23*404b540aSrobert   }
24*404b540aSrobert }
25*404b540aSrobert int
main()26*404b540aSrobert main ()
27*404b540aSrobert {
28*404b540aSrobert   f (2, A, A[0]);
29*404b540aSrobert   return 0;
30*404b540aSrobert }
31