mirror-llvm-project/flang/test/Parser/OpenMP/map-modifiers-v60.f90
Krzysztof Parzyszek ce1c15a062 [flang][OpenMP] Version-dependent parsing of map-type-modifier
Up until 5.2, ALWAYS, CLOSE, and PRESENT were keywords of the
map-type-modifier. Starting from 6.0 they all became their own
single-keyword modifiers. This allowed specifying them together,
unlike in the past where map-type-modifier was unique.

To avoid using a single representation of the modifiers, and be
able to validate them through non-conditional properties, the
AST was rewritten back to the older form in canonicalization
when the spec version was set to 5.2 or earlier.

Now that the parser is version-aware, it can generate the desired
AST from the start.

Additionally, extract the OMPX_HOLD modifier out of the map-type-
modifier into its own AST node regardless of version.
2026-08-01 12:53:25 -05:00

113 lines
3.8 KiB
Fortran

!RUN: %flang_fc1 -fdebug-unparse -fopenmp -fopenmp-version=60 %s | FileCheck --ignore-case --check-prefix="UNPARSE" %s
!RUN: %flang_fc1 -fdebug-dump-parse-tree -fopenmp -fopenmp-version=60 %s | FileCheck --check-prefix="PARSE-TREE" %s
subroutine f00(x)
integer :: x
!$omp target map(always, close, delete, present, ompx_hold: x)
x = x + 1
!$omp end target
end
!UNPARSE: SUBROUTINE f00 (x)
!UNPARSE: INTEGER x
!UNPARSE: !$OMP TARGET MAP(ALWAYS, CLOSE, DELETE, PRESENT, OMPX_HOLD: x)
!UNPARSE: x=x+1_4
!UNPARSE: !$OMP END TARGET
!UNPARSE: END SUBROUTINE
!PARSE-TREE: OmpBeginDirective
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = target
!PARSE-TREE: | OmpClauseList -> OmpClause -> Map -> OmpMapClause
!PARSE-TREE: | | Modifier -> OmpAlwaysModifier -> Value = Always
!PARSE-TREE: | | Modifier -> OmpCloseModifier -> Value = Close
!PARSE-TREE: | | Modifier -> OmpDeleteModifier -> Value = Delete
!PARSE-TREE: | | Modifier -> OmpPresentModifier -> Value = Present
!PARSE-TREE: | | Modifier -> OmpxHoldModifier -> Value = Ompx_Hold
!PARSE-TREE: | | OmpObjectList -> OmpObject -> Designator -> DataRef -> Name = 'x'
!PARSE-TREE: | | bool = 'true'
subroutine f01(x)
integer :: x
!$omp target map(self, storage: x)
x = x + 1
!$omp end target
end
!UNPARSE: !$OMP TARGET MAP(SELF, STORAGE: x)
!UNPARSE: x=x+1_4
!UNPARSE: !$OMP END TARGET
!UNPARSE: END SUBROUTINE
!PARSE-TREE: OmpBeginDirective
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = target
!PARSE-TREE: | OmpClauseList -> OmpClause -> Map -> OmpMapClause
!PARSE-TREE: | | Modifier -> OmpSelfModifier -> Value = Self
!PARSE-TREE: | | Modifier -> OmpMapType -> Value = Storage
!PARSE-TREE: | | OmpObjectList -> OmpObject -> Designator -> DataRef -> Name = 'x'
!PARSE-TREE: | | bool = 'true'
subroutine f02(x)
integer, pointer :: x
!$omp target map(ref_ptr, to: x)
x = x + 1
!$omp end target
end
!UNPARSE: SUBROUTINE f02 (x)
!UNPARSE: INTEGER, POINTER :: x
!UNPARSE: !$OMP TARGET MAP(REF_PTR, TO: x)
!UNPARSE: x=x+1_4
!UNPARSE: !$OMP END TARGET
!UNPARSE: END SUBROUTINE
!PARSE-TREE: OmpBeginDirective
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = target
!PARSE-TREE: | OmpClauseList -> OmpClause -> Map -> OmpMapClause
!PARSE-TREE: | | Modifier -> OmpRefModifier -> Value = Ref_Ptr
!PARSE-TREE: | | Modifier -> OmpMapType -> Value = To
!PARSE-TREE: | | OmpObjectList -> OmpObject -> Designator -> DataRef -> Name = 'x'
!PARSE-TREE: | | bool = 'true'
subroutine f03(x)
integer, pointer :: x
!$omp target map(ref_ptee, to: x)
x = x + 1
!$omp end target
end
!UNPARSE: SUBROUTINE f03 (x)
!UNPARSE: INTEGER, POINTER :: x
!UNPARSE: !$OMP TARGET MAP(REF_PTEE, TO: x)
!UNPARSE: x=x+1_4
!UNPARSE: !$OMP END TARGET
!UNPARSE: END SUBROUTINE
!PARSE-TREE: OmpBeginDirective
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = target
!PARSE-TREE: | OmpClauseList -> OmpClause -> Map -> OmpMapClause
!PARSE-TREE: | | Modifier -> OmpRefModifier -> Value = Ref_Ptee
!PARSE-TREE: | | Modifier -> OmpMapType -> Value = To
!PARSE-TREE: | | OmpObjectList -> OmpObject -> Designator -> DataRef -> Name = 'x'
!PARSE-TREE: | | bool = 'true'
subroutine f04(x)
integer, pointer :: x
!$omp target map(ref_ptr_ptee, to: x)
x = x + 1
!$omp end target
end
!UNPARSE: SUBROUTINE f04 (x)
!UNPARSE: INTEGER, POINTER :: x
!UNPARSE: !$OMP TARGET MAP(REF_PTR_PTEE, TO: x)
!UNPARSE: x=x+1_4
!UNPARSE: !$OMP END TARGET
!UNPARSE: END SUBROUTINE
!PARSE-TREE: OmpBeginDirective
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = target
!PARSE-TREE: | OmpClauseList -> OmpClause -> Map -> OmpMapClause
!PARSE-TREE: | | Modifier -> OmpRefModifier -> Value = Ref_Ptr_Ptee
!PARSE-TREE: | | Modifier -> OmpMapType -> Value = To
!PARSE-TREE: | | OmpObjectList -> OmpObject -> Designator -> DataRef -> Name = 'x'
!PARSE-TREE: | | bool = 'true'