44 lines · plain
1! This test validates that declare mapper for a derived type that extends2! a parent type with an allocatable component correctly maps the nested3! allocatable payload via the mapper when the whole object is mapped on4! target.5 6! REQUIRES: flang, amdgpu7 8! RUN: %libomptarget-compile-fortran-run-and-check-generic9 10program target_declare_mapper_parent_allocatable11 implicit none12 13 type, abstract :: base_t14 real, allocatable :: base_arr(:)15 end type base_t16 17 type, extends(base_t) :: real_t18 real, allocatable :: real_arr(:)19 end type real_t20 !$omp declare mapper(custommapper: real_t :: t) map(t%base_arr, t%real_arr)21 22 type(real_t) :: r23 integer :: i24 allocate(r%base_arr(10), source=1.0)25 allocate(r%real_arr(10), source=1.0)26 27 !$omp target map(mapper(custommapper), tofrom: r)28 do i = 1, size(r%base_arr)29 r%base_arr(i) = 2.030 r%real_arr(i) = 3.031 r%real_arr(i) = r%base_arr(1)32 end do33 !$omp end target34 35 36 !CHECK: base_arr: 2. 2. 2. 2. 2. 2. 2. 2. 2. 2.37 print*, "base_arr: ", r%base_arr38 !CHECK: real_arr: 2. 2. 2. 2. 2. 2. 2. 2. 2. 2.39 print*, "real_arr: ", r%real_arr40 41 deallocate(r%real_arr)42 deallocate(r%base_arr)43end program target_declare_mapper_parent_allocatable44