Index: flang/include/flang/Parser/parse-tree.h =================================================================== --- flang/include/flang/Parser/parse-tree.h +++ flang/include/flang/Parser/parse-tree.h @@ -3347,7 +3347,7 @@ struct OmpDefaultmapClause { TUPLE_CLASS_BOILERPLATE(OmpDefaultmapClause); ENUM_CLASS(ImplicitBehavior, Alloc, To, From, Tofrom, Firstprivate, None, Default) - ENUM_CLASS(VariableCategory, Scalar) + ENUM_CLASS(VariableCategory, Scalar, Aggregate, Allocatable, Pointer) std::tuple> t; }; Index: flang/lib/Parser/openmp-parsers.cpp =================================================================== --- flang/lib/Parser/openmp-parsers.cpp +++ flang/lib/Parser/openmp-parsers.cpp @@ -56,15 +56,19 @@ TYPE_PARSER(construct( construct( "ALLOC" >> pure(OmpDefaultmapClause::ImplicitBehavior::Alloc) || - "TO" >> pure(OmpDefaultmapClause::ImplicitBehavior::To) || + "TO"_id >> pure(OmpDefaultmapClause::ImplicitBehavior::To) || "FROM" >> pure(OmpDefaultmapClause::ImplicitBehavior::From) || "TOFROM" >> pure(OmpDefaultmapClause::ImplicitBehavior::Tofrom) || "FIRSTPRIVATE" >> pure(OmpDefaultmapClause::ImplicitBehavior::Firstprivate) || "NONE" >> pure(OmpDefaultmapClause::ImplicitBehavior::None) || "DEFAULT" >> pure(OmpDefaultmapClause::ImplicitBehavior::Default) ), - maybe(":" >> construct("SCALAR" >> - pure(OmpDefaultmapClause::VariableCategory::Scalar))))) + maybe(":" >> construct( + "SCALAR" >> pure(OmpDefaultmapClause::VariableCategory::Scalar) || + "AGGREGATE" >> pure(OmpDefaultmapClause::VariableCategory::Aggregate) || + "ALLOCATABLE" >> pure(OmpDefaultmapClause::VariableCategory::Allocatable) || + "POINTER" >> pure(OmpDefaultmapClause::VariableCategory::Pointer) + )))) // 2.7.1 SCHEDULE ([modifier1 [, modifier2]:]kind[, chunk_size]) // Modifier -> MONITONIC | NONMONOTONIC | SIMD Index: flang/test/Parser/omp-defaultmap-unparse.f90 =================================================================== --- flang/test/Parser/omp-defaultmap-unparse.f90 +++ flang/test/Parser/omp-defaultmap-unparse.f90 @@ -1,16 +1,34 @@ ! RUN: %flang_fc1 -fdebug-unparse-no-sema -fopenmp %s | FileCheck %s + program main - real(8) :: arrayA(256), arrayB(256) - integer :: N + implicit none + + integer, parameter :: N = 256 + + type data01 + integer :: a + integer :: arr(N) + end type + + real :: arrA(N), arrB(N) + integer, target :: arrC(N) + type(data01) :: data01_a + integer, allocatable :: alloc_arr(:) + integer, pointer :: ptrArr(:) + + arrA = 1.414 + arrB = 3.14 + arrC = -1 + data01_a%a = -1 + data01_arr = -1 + allocate(alloc_arr(N)) + alloc_arr = -1 - arrayA = 1.414 - arrayB = 3.14 - N = 256 !$omp target defaultmap(tofrom:scalar) do i = 1, N - a = 3.14 + a = 3.14 enddo !$omp end target @@ -26,6 +44,31 @@ a = 4.78 !$omp end target + !$omp target defaultmap(to:scalar) + a = 2.39 + !$omp end target + + !$omp target defaultmap(firstprivate:scalar) + a = 9.45 + !$omp end target + + !$omp target defaultmap(tofrom:aggregate) + arrC(1) = 10 + data01_a%a = 11 + data01_a%arr(1) = 100 + data01_a%arr(2) = 245 + !$omp end target + + !$omp target defaultmap(tofrom:allocatable) + alloc_arr(23) = 234 + !$omp end target + + !$omp target defaultmap(default:pointer) + ptrArr=>arrC + ptrArr(2) = 5 + prtArr(200) = 34 + !$omp end target + end program main !CHECK-LABEL: PROGRAM main @@ -40,3 +83,18 @@ !CHECK: !$OMP TARGET DEFAULTMAP(NONE:SCALAR) !CHECK: !$OMP END TARGET + +!CHECK: !$OMP TARGET DEFAULTMAP(TO:SCALAR) +!CHECK: !$OMP END TARGET + +!CHECK: !$OMP TARGET DEFAULTMAP(FIRSTPRIVATE:SCALAR) +!CHECK: !$OMP END TARGET + +!CHECK: !$OMP TARGET DEFAULTMAP(TOFROM:AGGREGATE) +!CHECK: !$OMP END TARGET + +!CHECK: !$OMP TARGET DEFAULTMAP(TOFROM:ALLOCATABLE) +!CHECK: !$OMP END TARGET + +!CHECK: !$OMP TARGET DEFAULTMAP(DEFAULT:POINTER) +!CHECK: !$OMP END TARGET