1  /* Test data clause diagnostics.  */
       2  
       3  /* See also corresponding OpenACC C++ variant: '../../g++.dg/goacc/data-clause-1.C'.  */
       4  
       5  /* See also corresponding OpenACC 'cache' directive variant: 'cache-3-1.c'.  */
       6  
       7  /* See also corresponding OpenMP variant: '../gomp/map-1.c'.  */
       8  
       9  /* { dg-additional-options "-fopenmp" } for '#pragma omp threadprivate'.  */
      10  
      11  extern int a[][10], a2[][10];
      12  int b[10], c[10][2], d[10], e[10], f[10];
      13  int b2[10], c2[10][2], d2[10], e2[10], f2[10];
      14  int k[10], l[10], m[10], n[10], o;
      15  int *p;
      16  int **q;
      17  int r[4][4][4][4][4];
      18  extern struct s s1;
      19  extern struct s s2[1]; /* { dg-error "array type has incomplete element type" "" { target c } } */
      20  int t[10];
      21  #pragma omp threadprivate (t)
      22  #pragma acc routine
      23  void bar (int *);
      24  
      25  void
      26  foo (int g[3][10], int h[4][8], int i[2][10], int j[][9],
      27       int g2[3][10], int h2[4][8], int i2[2][10], int j2[][9])
      28  {
      29    #pragma acc parallel copyin(bar[2:5]) /* { dg-error "is not a variable" } */
      30      ;
      31    #pragma acc parallel copyout(t[2:5]) /* { dg-error "is threadprivate variable" } */
      32      ;
      33    #pragma acc parallel copy(k[0.5:]) /* { dg-error "low bound \[^\n\r]* of array section does not have integral type" } */
      34      ;
      35    #pragma acc parallel copyout(l[:7.5f]) /* { dg-error "length \[^\n\r]* of array section does not have integral type" } */
      36      ;
      37    #pragma acc parallel copyin(m[p:]) /* { dg-error "low bound \[^\n\r]* of array section does not have integral type" } */
      38      ;
      39    #pragma acc parallel copy(n[:p]) /* { dg-error "length \[^\n\r]* of array section does not have integral type" } */
      40      ;
      41    #pragma acc parallel copyin(o[2:5]) /* { dg-error "does not have pointer or array type" } */
      42      ;
      43    #pragma acc parallel create(s1) /* { dg-error "'s1' does not have a mappable type in 'map' clause" } */
      44      ;
      45    #pragma acc parallel create(s2) /* { dg-error "'s2' does not have a mappable type in 'map' clause" } */
      46      ;
      47    #pragma acc parallel copyin(a[:][:]) /* { dg-error "array type length expression must be specified" } */
      48      bar (&a[0][0]); /* { dg-error "referenced in target region does not have a mappable type" } */
      49    #pragma acc parallel copy(b[-1:]) /* { dg-error "negative low bound in array section" } */
      50      bar (b);
      51    #pragma acc parallel copy(c[:-3][:]) /* { dg-error "negative length in array section" } */
      52      bar (&c[0][0]);
      53    #pragma acc parallel copyout(d[11:]) /* { dg-error "low bound \[^\n\r]* above array section size" } */
      54      bar (d);
      55    #pragma acc parallel copyin(e[:11]) /* { dg-error "length \[^\n\r]* above array section size" } */
      56      bar (e);
      57    #pragma acc parallel copyin(f[1:10]) /* { dg-error "high bound \[^\n\r]* above array section size" } */
      58      bar (f);
      59    #pragma acc parallel copyout(g[:][0:10]) /* { dg-error "for array function parameter length expression must be specified" } */
      60      bar (&g[0][0]);
      61    #pragma acc parallel copyout(h[2:1][-1:]) /* { dg-error "negative low bound in array section" } */
      62      bar (&h[0][0]);
      63    #pragma acc parallel copy(h[:1][:-3]) /* { dg-error "negative length in array section" } */
      64      bar (&h[0][0]);
      65    #pragma acc parallel copy(i[:1][11:]) /* { dg-error "low bound \[^\n\r]* above array section size" } */
      66      bar (&i[0][0]);
      67    #pragma acc parallel copyout(j[3:1][:10]) /* { dg-error "length \[^\n\r]* above array section size" } */
      68      bar (&j[0][0]);
      69    #pragma acc parallel copyin(j[30:1][5:5]) /* { dg-error "high bound \[^\n\r]* above array section size" } */
      70      bar (&j[0][0]);
      71    #pragma acc parallel copyin(a2[:1][2:4])
      72      bar (&a2[0][0]);
      73    #pragma acc parallel copy(a2[3:5][:])
      74      bar (&a2[0][0]);
      75    #pragma acc parallel copyin(a2[3:5][:10])
      76      bar (&a2[0][0]);
      77    #pragma acc parallel copy(b2[0:])
      78      bar (b2);
      79    #pragma acc parallel copy(c2[:3][:])
      80      bar (&c2[0][0]);
      81    #pragma acc parallel copyout(d2[9:])
      82      bar (d2);
      83    #pragma acc parallel copyin(e2[:10])
      84      bar (e2);
      85    #pragma acc parallel copyin(f2[1:9])
      86      bar (f2);
      87    #pragma acc parallel copy(g2[:1][2:4])
      88      bar (&g2[0][0]);
      89    #pragma acc parallel copyout(h2[2:2][0:])
      90      bar (&h2[0][0]);
      91    #pragma acc parallel copy(h2[:1][:3])
      92      bar (&h2[0][0]);
      93    #pragma acc parallel copyin(i2[:1][9:])
      94      bar (&i2[0][0]);
      95    #pragma acc parallel copyout(j2[3:4][:9])
      96      bar (&j2[0][0]);
      97    #pragma acc parallel copyin(j2[30:1][5:4])
      98      bar (&j2[0][0]);
      99    #pragma acc parallel copy(q[1:2])
     100      ;
     101    #pragma acc parallel copy(q[3:5][:10]) /* { dg-error "array section is not contiguous" } */
     102      ;
     103    #pragma acc parallel copy(r[3:][2:1][1:2])
     104      ;
     105    #pragma acc parallel copy(r[3:][2:1][1:2][:][0:4])
     106      ;
     107    #pragma acc parallel copy(r[3:][2:1][1:2][1:][0:4]) /* { dg-error "array section is not contiguous" } */
     108      ;
     109    #pragma acc parallel copy(r[3:][2:1][1:2][:3][0:4]) /* { dg-error "array section is not contiguous" } */
     110      ;
     111    #pragma acc parallel copy(r[3:][2:1][1:2][:][1:]) /* { dg-error "array section is not contiguous" } */
     112      ;
     113    #pragma acc parallel copy(r[3:][2:1][1:2][:][:3]) /* { dg-error "array section is not contiguous" } */
     114      ;
     115  }