libgomp testsuite: OpenACC C++ testing.
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / lib-68.c
blob3ff5bd7bcf7a2e206b05cf096547a1a91f2e13e2
1 /* { dg-do run } */
3 #include <string.h>
4 #include <stdlib.h>
5 #include <openacc.h>
7 int
8 main (int argc, char **argv)
10 const int N = 256;
11 int i;
12 unsigned char *h;
13 void *d;
15 h = (unsigned char *) malloc (N);
17 for (i = 0; i < N; i++)
19 h[i] = i;
22 d = acc_malloc (N);
24 acc_memcpy_to_device (d, h, N);
26 memset (&h[0], 0, N);
28 acc_memcpy_from_device (h, 0, N);
30 for (i = 0; i < N; i++)
32 if (h[i] != i)
33 abort ();
36 acc_free (d);
38 free (h);
40 return 0;
43 /* { dg-shouldfail "libgomp: invalid device address" } */