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