aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/goacc/host_data-2.c
blob: 862a764eb3acda326cf607dd1e83f05854eb7d03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* Test invalid use of host_data directive.  */

int v0;
#pragma acc host_data use_device(v0) /* { dg-error "expected declaration specifiers before" } */


void
f (void)
{
  int v2 = 3;
#pragma acc host_data copy(v2)
  /* { dg-error ".copy. is not valid for ..pragma acc host_data." "" { target *-*-* } .-1 } */
  /* { dg-error ".host_data. construct requires .use_device. clause" "" { target *-*-* } .-2 } */
  ;

#pragma acc host_data use_device(v2)
  /* { dg-error ".use_device_ptr. variable is neither a pointer nor an array" "" { target c } .-1 } */
  /* { dg-error ".use_device_ptr. variable is neither a pointer, nor an array nor reference to pointer or array" "" { target c++ } .-2 } */
  ;
  
#pragma acc host_data use_device(v0)
  /* { dg-error ".use_device_ptr. variable is neither a pointer nor an array" "" { target c } .-1 } */
  /* { dg-error ".use_device_ptr. variable is neither a pointer, nor an array nor reference to pointer or array" "" { target c++ } .-2 } */
  ;

#pragma acc host_data /* { dg-error ".host_data. construct requires .use_device. clause" } */
  ;
}


void
f2 (void)
{
  int x[100];

#pragma acc enter data copyin (x)
  /* Specifying an array index is not valid for host_data/use_device.  */
#pragma acc host_data use_device (x[4]) /* { dg-error "expected '\\\)' before '\\\[' token" } */
  ;
#pragma acc exit data delete (x)
}


void
f3 (void)
{
  int x[100];

#pragma acc data copyin (x[25:50])
  {
    int *xp;
#pragma acc host_data use_device (x)
    {
      /* This use of the present clause is undefined behavior for OpenACC.  */
#pragma acc parallel present (x) copyout (xp) /* { dg-error "variable .x. declared in enclosing .host_data. region" } */
      {
        xp = x;
      }
    }
  }
}


void
f4 (void)
{
  int x[50];

#pragma acc data copyin (x[10:30])
  {
    int *xp;
#pragma acc host_data use_device (x)
    {
      /* Here 'x' being implicitly firstprivate for the parallel region
	 conflicts with it being declared as use_device in the enclosing
	 host_data region.  */
#pragma acc parallel copyout (xp)
      {
        xp = x; /* { dg-error "variable .x. declared in enclosing .host_data. region" } */
      }
    }
  }
}