Bump version to 19.1.0-rc3
[llvm-project.git] / offload / test / mapping / pr38704.c
blob72b4a171ccea474238566aba53c39b175e895d26
1 // RUN: %libomptarget-compile-run-and-check-generic
3 // Clang 6.0 doesn't use the new map interface, undefined behavior when
4 // the compiler emits "old" interface code for structures.
5 // UNSUPPORTED: clang-6
7 #include <stdio.h>
8 #include <stdlib.h>
10 typedef struct {
11 int *ptr1;
12 int *ptr2;
13 } StructWithPtrs;
15 int main(int argc, char *argv[]) {
16 StructWithPtrs s, s2;
17 s.ptr1 = malloc(sizeof(int));
18 s.ptr2 = malloc(2 * sizeof(int));
19 s2.ptr1 = malloc(sizeof(int));
20 s2.ptr2 = malloc(2 * sizeof(int));
22 #pragma omp target enter data map(to : s2.ptr2[0 : 1])
23 #pragma omp target map(s.ptr1[0 : 1], s.ptr2[0 : 2])
25 s.ptr1[0] = 1;
26 s.ptr2[0] = 2;
27 s.ptr2[1] = 3;
29 #pragma omp target exit data map(from : s2.ptr1[0 : 1], s2.ptr2[0 : 1])
31 // CHECK: s.ptr1[0] = 1
32 // CHECK: s.ptr2[0] = 2
33 // CHECK: s.ptr2[1] = 3
34 printf("s.ptr1[0] = %d\n", s.ptr1[0]);
35 printf("s.ptr2[0] = %d\n", s.ptr2[0]);
36 printf("s.ptr2[1] = %d\n", s.ptr2[1]);
38 free(s.ptr1);
39 free(s.ptr2);
40 free(s2.ptr1);
41 free(s2.ptr2);
43 return 0;