Debian Codegraph @

gcc/testsuite/c-c++-common/goacc/host_data-2.c

raw
1 /* Test invalid use of host_data directive. */
2
3 int v0;
4 #pragma acc host_data use_device(v0) /* { dg-error "expected declaration specifiers before" } */
5
6
7 void
8 f (void)
9 {
10 int v2 = 3;
11 #pragma acc host_data copy(v2)
12 /* { dg-error ".copy. is not valid for ..pragma acc host_data." "" { target *-*-* } .-1 } */
13 /* { dg-error ".host_data. construct requires .use_device. clause" "" { target *-*-* } .-2 } */
14 ;
15
16 #pragma acc host_data use_device(v2)
17 /* { dg-error ".use_device_ptr. variable is neither a pointer nor an array" "" { target c } .-1 } */
18 /* { dg-error ".use_device_ptr. variable is neither a pointer, nor an array nor reference to pointer or array" "" { target c++ } .-2 } */
19 ;
20
21 #pragma acc host_data use_device(v0)
22 /* { dg-error ".use_device_ptr. variable is neither a pointer nor an array" "" { target c } .-1 } */
23 /* { dg-error ".use_device_ptr. variable is neither a pointer, nor an array nor reference to pointer or array" "" { target c++ } .-2 } */
24 ;
25
26 #pragma acc host_data /* { dg-error ".host_data. construct requires .use_device. clause" } */
27 ;
28 }
29
30
31 void
32 f2 (void)
33 {
34 int x[100];
35
36 #pragma acc enter data copyin (x)
37 /* Specifying an array index is not valid for host_data/use_device. */
38 #pragma acc host_data use_device (x[4]) /* { dg-error "expected '\\\)' before '\\\[' token" } */
39 ;
40 #pragma acc exit data delete (x)
41 }
42
43
44 void
45 f3 (void)
46 {
47 int x[100];
48
49 #pragma acc data copyin (x[25:50])
50 {
51 int *xp;
52 #pragma acc host_data use_device (x)
53 {
54 /* This use of the present clause is undefined behavior for OpenACC. */
55 #pragma acc parallel present (x) copyout (xp) /* { dg-error "variable .x. declared in enclosing .host_data. region" } */
56 {
57 xp = x;
58 }
59 }
60 }
61 }
62
63
64 void
65 f4 (void)
66 {
67 int x[50];
68
69 #pragma acc data copyin (x[10:30])
70 {
71 int *xp;
72 #pragma acc host_data use_device (x)
73 {
74 /* Here 'x' being implicitly firstprivate for the parallel region
75 conflicts with it being declared as use_device in the enclosing
76 host_data region. */
77 #pragma acc parallel copyout (xp)
78 {
79 xp = x; /* { dg-error "variable .x. declared in enclosing .host_data. region" } */
80 }
81 }
82 }
83 }