diff options
| author | Krzysztof Parzyszek <Krzysztof.Parzyszek@amd.com> | 2025-01-03 09:21:36 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-03 09:21:36 -0600 |
| commit | adeff9f63a24f60b0bf240bf13e40bbf7c1dd0e8 (patch) | |
| tree | 8aebe64472690d32ddab559d81121be2515deeca /flang/test/Parser/OpenMP | |
| parent | a4d92400a6db9566d84cb4b900149e36e117f452 (diff) | |
[flang][OpenMP] Allow utility constructs in specification part (#121509)
Allow utility constructs (error and nothing) to appear in the
specification part as well as the execution part. The exception is
"ERROR AT(EXECUTION)" which should only be in the execution part.
In case of ambiguity (the boundary between the specification and the
execution part), utility constructs will be parsed as belonging to the
specification part. In such cases move them to the execution part in the
OpenMP canonicalization code.
Diffstat (limited to 'flang/test/Parser/OpenMP')
| -rw-r--r-- | flang/test/Parser/OpenMP/error-unparse.f90 | 18 | ||||
| -rw-r--r-- | flang/test/Parser/OpenMP/nothing.f90 | 100 |
2 files changed, 111 insertions, 7 deletions
diff --git a/flang/test/Parser/OpenMP/error-unparse.f90 b/flang/test/Parser/OpenMP/error-unparse.f90 index 4dd06b736da8..2cb4e1a083a6 100644 --- a/flang/test/Parser/OpenMP/error-unparse.f90 +++ b/flang/test/Parser/OpenMP/error-unparse.f90 @@ -1,23 +1,27 @@ -! RUN: %flang_fc1 -fopenmp-version=51 -fopenmp -fdebug-unparse-no-sema %s 2>&1 | FileCheck %s -! RUN: %flang_fc1 -fopenmp-version=51 -fopenmp -fdebug-dump-parse-tree-no-sema %s 2>&1 | FileCheck %s --check-prefix="PARSE-TREE" +! RUN: %flang_fc1 -fopenmp-version=51 -fopenmp -fdebug-unparse %s 2>&1 | FileCheck %s +! RUN: %flang_fc1 -fopenmp-version=51 -fopenmp -fdebug-dump-parse-tree %s 2>&1 | FileCheck %s --check-prefix="PARSE-TREE" program main character(*), parameter :: message = "This is an error" !CHECK: !$OMP ERROR AT(COMPILATION) SEVERITY(WARNING) MESSAGE("some message here") !PARSE-TREE: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPUtilityConstruct -> OmpErrorDirective !PARSE-TREE: OmpClauseList -> OmpClause -> At -> OmpAtClause -> ActionTime = Compilation !PARSE-TREE: OmpClause -> Severity -> OmpSeverityClause -> Severity = Warning - !PARSE-TREE: OmpClause -> Message -> OmpMessageClause -> Expr -> LiteralConstant -> CharLiteralConstant + !PARSE-TREE: OmpClause -> Message -> OmpMessageClause -> Expr = '"some message here"' + !PARSE-TREE: LiteralConstant -> CharLiteralConstant + !PARSE-TREE: string = 'some message here' !$omp error at(compilation) severity(warning) message("some message here") - !CHECK: !$OMP ERROR AT(COMPILATION) SEVERITY(FATAL) MESSAGE(message) + !CHECK: !$OMP ERROR AT(COMPILATION) SEVERITY(FATAL) MESSAGE("This is an error") !PARSE-TREE: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPUtilityConstruct -> OmpErrorDirective !PARSE-TREE: OmpClauseList -> OmpClause -> At -> OmpAtClause -> ActionTime = Compilation !PARSE-TREE: OmpClause -> Severity -> OmpSeverityClause -> Severity = Fatal - !PARSE-TREE: OmpClause -> Message -> OmpMessageClause -> Expr -> Designator -> DataRef -> Name = 'message' + !PARSE-TREE: OmpClause -> Message -> OmpMessageClause -> Expr = '"This is an error"' + !PARSE-TREE: Designator -> DataRef -> Name = 'message' !$omp error at(compilation) severity(fatal) message(message) - !CHECK: !$OMP ERROR AT(EXECUTION) SEVERITY(FATAL) MESSAGE(message) + !CHECK: !$OMP ERROR AT(EXECUTION) SEVERITY(FATAL) MESSAGE("This is an error") !PARSE-TREE: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPUtilityConstruct -> OmpErrorDirective !PARSE-TREE: OmpClauseList -> OmpClause -> At -> OmpAtClause -> ActionTime = Execution !PARSE-TREE: OmpClause -> Severity -> OmpSeverityClause -> Severity = Fatal - !PARSE-TREE: OmpClause -> Message -> OmpMessageClause -> Expr -> Designator -> DataRef -> Name = 'message' + !PARSE-TREE: OmpClause -> Message -> OmpMessageClause -> Expr = '"This is an error"' + !PARSE-TREE: Designator -> DataRef -> Name = 'message' !$omp error at(EXECUTION) severity(fatal) message(message) end program main diff --git a/flang/test/Parser/OpenMP/nothing.f90 b/flang/test/Parser/OpenMP/nothing.f90 index 80c093208761..22558c493c44 100644 --- a/flang/test/Parser/OpenMP/nothing.f90 +++ b/flang/test/Parser/OpenMP/nothing.f90 @@ -11,3 +11,103 @@ end !PARSE-TREE: ExecutionPart -> Block !PARSE-TREE: | | ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPUtilityConstruct -> OmpNothingDirective + +subroutine f01 + block + import, none + integer :: x + !$omp nothing ! "nothing" in the execution part + x = x+1 + end block +end + +!UNPARSE: SUBROUTINE f01 +!UNPARSE: BLOCK +!UNPARSE: IMPORT, NONE +!UNPARSE: INTEGER x +!UNPARSE: !$OMP NOTHING +!UNPARSE: x=x+1_4 +!UNPARSE: END BLOCK +!UNPARSE: END SUBROUTINE + +!PARSE-TREE: BlockStmt -> +!PARSE-TREE: BlockSpecificationPart -> SpecificationPart +!PARSE-TREE: | ImportStmt +!PARSE-TREE: | ImplicitPart -> +!PARSE-TREE: | DeclarationConstruct -> SpecificationConstruct -> TypeDeclarationStmt +!PARSE-TREE: | | DeclarationTypeSpec -> IntrinsicTypeSpec -> IntegerTypeSpec -> +!PARSE-TREE: | | EntityDecl +!PARSE-TREE: | | | Name = 'x' +!PARSE-TREE: Block +!PARSE-TREE: | ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPUtilityConstruct -> OmpNothingDirective +!PARSE-TREE: | ExecutionPartConstruct -> ExecutableConstruct -> ActionStmt -> AssignmentStmt = 'x=x+1_4' +!PARSE-TREE: | | Variable = 'x' +!PARSE-TREE: | | | Designator -> DataRef -> Name = 'x' +!PARSE-TREE: | | Expr = 'x+1_4' +!PARSE-TREE: | | | Add +!PARSE-TREE: | | | | Expr = 'x' +!PARSE-TREE: | | | | | Designator -> DataRef -> Name = 'x' +!PARSE-TREE: | | | | Expr = '1_4' +!PARSE-TREE: | | | | | LiteralConstant -> IntLiteralConstant = '1' +!PARSE-TREE: EndBlockStmt -> + +subroutine f02 + integer :: x + !$omp nothing +end + +!UNPARSE: SUBROUTINE f02 +!UNPARSE: INTEGER x +!UNPARSE: !$OMP NOTHING +!UNPARSE: END SUBROUTINE + +!PARSE-TREE: SpecificationPart +!PARSE-TREE: | ImplicitPart -> +!PARSE-TREE: | DeclarationConstruct -> SpecificationConstruct -> TypeDeclarationStmt +!PARSE-TREE: | | DeclarationTypeSpec -> IntrinsicTypeSpec -> IntegerTypeSpec -> +!PARSE-TREE: | | EntityDecl +!PARSE-TREE: | | | Name = 'x' +!PARSE-TREE: ExecutionPart -> Block +!PARSE-TREE: | ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPUtilityConstruct -> OmpNothingDirective + +subroutine f03 + block + !$omp nothing ! "nothing" in the specification part + import, none + integer :: x + x = x+1 + end block +end + +!UNPARSE: SUBROUTINE f03 +!UNPARSE: BLOCK +!UNPARSE: !$OMP NOTHING +!UNPARSE: IMPORT, NONE +!UNPARSE: INTEGER x +!UNPARSE: x=x+1_4 +!UNPARSE: END BLOCK +!UNPARSE: END SUBROUTINE + +!PARSE-TREE: ExecutionPart -> Block +!PARSE-TREE: | ExecutionPartConstruct -> ExecutableConstruct -> BlockConstruct +!PARSE-TREE: | | BlockStmt -> +!PARSE-TREE: | | BlockSpecificationPart -> SpecificationPart +!PARSE-TREE: | | | OpenMPDeclarativeConstruct -> OpenMPUtilityConstruct -> OmpNothingDirective +!PARSE-TREE: | | | ImportStmt +!PARSE-TREE: | | | ImplicitPart -> +!PARSE-TREE: | | | DeclarationConstruct -> SpecificationConstruct -> TypeDeclarationStmt +!PARSE-TREE: | | | | DeclarationTypeSpec -> IntrinsicTypeSpec -> IntegerTypeSpec -> +!PARSE-TREE: | | | | EntityDecl +!PARSE-TREE: | | | | | Name = 'x' +!PARSE-TREE: | | Block +!PARSE-TREE: | | | ExecutionPartConstruct -> ExecutableConstruct -> ActionStmt -> AssignmentStmt = 'x=x+1_4' +!PARSE-TREE: | | | | Variable = 'x' +!PARSE-TREE: | | | | | Designator -> DataRef -> Name = 'x' +!PARSE-TREE: | | | | Expr = 'x+1_4' +!PARSE-TREE: | | | | | Add +!PARSE-TREE: | | | | | | Expr = 'x' +!PARSE-TREE: | | | | | | | Designator -> DataRef -> Name = 'x' +!PARSE-TREE: | | | | | | Expr = '1_4' +!PARSE-TREE: | | | | | | | LiteralConstant -> IntLiteralConstant = '1' +!PARSE-TREE: | | EndBlockStmt -> +!PARSE-TREE: EndSubroutineStmt ->
\ No newline at end of file |
