[flang-commits] [flang] 3722103 - write semantics tests for CHANGE TEAM statement.
Hussain Kadhem via flang-commits
flang-commits at lists.llvm.org
Mon Mar 27 12:54:38 PDT 2023
Author: Hussain Kadhem
Date: 2023-03-27T12:53:26-07:00
New Revision: 372210308e0bd66e79d570dc11b2ed1b47a4a63c
URL: https://github.com/llvm/llvm-project/commit/372210308e0bd66e79d570dc11b2ed1b47a4a63c
DIFF: https://github.com/llvm/llvm-project/commit/372210308e0bd66e79d570dc11b2ed1b47a4a63c.diff
LOG: write semantics tests for CHANGE TEAM statement.
Added semantics tests for aspects of CHANGE TEAM statements which are not duplicates from FORM TEAM statements.
Reviewed By: ktras
Differential Revision: https://reviews.llvm.org/D137908
Added:
flang/test/Semantics/change_team01.f90
flang/test/Semantics/change_team01b.f90
flang/test/Semantics/change_team01c.f90
Modified:
Removed:
################################################################################
diff --git a/flang/test/Semantics/change_team01.f90 b/flang/test/Semantics/change_team01.f90
new file mode 100644
index 0000000000000..43be1c10fb842
--- /dev/null
+++ b/flang/test/Semantics/change_team01.f90
@@ -0,0 +1,70 @@
+! RUN: %python %S/test_errors.py %s %flang_fc1
+! Check for semantic errors in change team statements.
+! Only those semantics which
diff er from those of FORM TEAM statements are checked.
+
+subroutine test
+ use, intrinsic :: iso_fortran_env, only: team_type
+ type(team_type) :: team
+ integer, codimension[*] :: selector
+ integer, codimension[2,*] :: selector2d
+
+ ! Valid invocations which should produce no errors.
+ block
+ change team (team)
+ end team
+ construct1: change team (team)
+ end team construct1
+ change team (team, ca[*] => selector)
+ end team
+ change team (team, ca[2,*] => selector)
+ end team
+ change team (team, ca[*] => selector)
+ end team
+ change team (team, ca[*] => selector, ca2[2,*] => selector2d)
+ end team
+ end block
+
+ !A selector may appear only once in selector-list.
+ ! ERROR: Selector 'selector' was already used as a selector or coarray in this statement
+ change team (team, ca[*] => selector, ca2[*] => selector)
+ end team
+
+ ! Within a CHANGE TEAM construct, a CYCLE or EXIT statement is not allowed if it belongs to an outer construct.
+ block
+ outer1: if (.true.) then
+ change team (team)
+ if (.true.) then
+ ! ERROR: EXIT must not leave a CHANGE TEAM statement
+ exit outer1
+ end if
+ end team
+ end if outer1
+ end block
+ block
+ outer2: do
+ change team (team)
+ ! ERROR: CYCLE must not leave a CHANGE TEAM statement
+ cycle outer2
+ end team
+ end do outer2
+ end block
+
+ ! The construct name must not be the same as any other construct name in the scoping unit.
+ block
+ construct2: block
+ end block construct2
+ ! ERROR: 'construct2' is already declared in this scoping unit
+ construct2: change team (team)
+ end team construct2
+ end block
+
+ ! When the CHANGE TEAM statement is executed, the selectors must all be established coarrays.
+ ! ERROR: Selector in coarray association must name a coarray
+ change team (team, ca[*] => not_selector)
+ end team
+
+ ! The coarray name in a coarray-association must not be the same as the name as the name of another coarray or of a selector in the CHANGE TEAM statement.
+ ! ERROR: 'selector' is not an object that can appear in an expression
+ change team (team, selector[*] => selector)
+ end team
+end subroutine
diff --git a/flang/test/Semantics/change_team01b.f90 b/flang/test/Semantics/change_team01b.f90
new file mode 100644
index 0000000000000..6435f22763285
--- /dev/null
+++ b/flang/test/Semantics/change_team01b.f90
@@ -0,0 +1,28 @@
+! RUN: %python %S/test_errors.py %s %flang_fc1
+! Check for semantic errors in change team statements
+! This subtest contains syntactic tests that prevent the main tests from being emitted.
+
+subroutine test
+ use, intrinsic :: iso_fortran_env, only: team_type
+ type(team_type) :: team
+
+ ! If a construct name appears on the CHANGE TEAM statement of the construct, the same name must also appear on the END TEAM construct.
+ block
+ construct: change team (team)
+ ! ERROR: CHANGE TEAM construct name required but missing
+ end team
+ end block
+ ! If a construct name appears on an END TEAM statement, the same construct name must appear on the corresponding CHANGE TEAM statement.
+ block
+ change team (team)
+ ! ERROR: CHANGE TEAM construct name unexpected
+ end team construct
+ end block
+ block
+ construct1: change team (team)
+ ! ERROR: CHANGE TEAM construct name mismatch
+ end team construct2
+ end block
+end subroutine
+
+
diff --git a/flang/test/Semantics/change_team01c.f90 b/flang/test/Semantics/change_team01c.f90
new file mode 100644
index 0000000000000..7ab8e852eae69
--- /dev/null
+++ b/flang/test/Semantics/change_team01c.f90
@@ -0,0 +1,31 @@
+! RUN: %python %S/test_errors.py %s %flang_fc1
+! XFAIL: *
+! Check for semantic errors in change team statements.
+! This subtest contains tests for unimplemented errors.
+
+subroutine test
+ use, intrinsic :: iso_fortran_env, only: team_type
+ type(team_type) :: team
+ integer, codimension[*] :: selector
+
+ ! A branch to an END TEAM statement is permitted only from within the corresponding CHANGE TEAM construct.
+ change team (team)
+ if (.true.) then
+ end team
+ end if
+ end team
+
+ ! A RETURN statement may not appear in a CHANGE TEAM construct.
+ change team (team)
+ ! ERROR: TBD
+ return
+ end team
+
+ ! On each image, the team variable specified in the CHANGE TEAM statement cannot become undefined or redefined during execution of the construct.
+ ! ERROR: TBD
+ change team (team)
+ team = get_team(INITIAL_TEAM)
+ end team
+end subroutine
+
+
More information about the flang-commits
mailing list