Skip to content

Commit

Permalink
[flang] Add team_type to num_images intrinsic call
Browse files Browse the repository at this point in the history
num_images had previously been added to the list of intrinsics
before the type team_type had been implemented. Now that team_type
is implemented, add the num_images call that has the team argument.
Update the semantics tests for num_images.

Reviewed By: craig.rasmussen

Differential Revision: https://reviews.llvm.org/D126734
  • Loading branch information
ktras committed Jun 14, 2022
1 parent e7c72d6 commit 473d780
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 2 additions & 0 deletions flang/lib/Evaluate/intrinsics.cpp
Expand Up @@ -629,6 +629,8 @@ static const IntrinsicInterface genericIntrinsicFunction[]{
// NULL() is a special case handled in Probe() below
{"num_images", {}, DefaultInt, Rank::scalar,
IntrinsicClass::transformationalFunction},
{"num_images", {{"team", TeamType, Rank::scalar}}, DefaultInt, Rank::scalar,
IntrinsicClass::transformationalFunction},
{"num_images", {{"team_number", AnyInt, Rank::scalar}}, DefaultInt,
Rank::scalar, IntrinsicClass::transformationalFunction},
{"out_of_range",
Expand Down
9 changes: 8 additions & 1 deletion flang/test/Semantics/num_images01.f90
Expand Up @@ -2,11 +2,17 @@
! Check for semantic errors in num_images() function calls

subroutine test
use iso_fortran_env, only: team_type
implicit none

type(team_type) my_team

! correct calls, should produce no errors
print *, num_images()
print *, num_images(team_number=1)
print *, num_images(1)
print *, num_images(my_team)
print *, num_images(team=my_team)

! incorrectly typed argument
! the error is seen as too many arguments to the num_images() call with no arguments
Expand All @@ -25,6 +31,7 @@ subroutine test
!ERROR: unknown keyword argument to intrinsic 'num_images'
print *, num_images(team_numbers=1)

!TODO: test num_images() calls related to team_type argument
!ERROR: unknown keyword argument to intrinsic 'num_images'
print *, num_images(teams=my_team)

end subroutine
6 changes: 1 addition & 5 deletions flang/test/Semantics/num_images02.f90
Expand Up @@ -21,12 +21,8 @@ program num_images_with_team_type
n = num_images(standard_initial_value)
n = num_images(coindexed[1])

!___ standard-conforming statements with team_type argument present (not yet supported) ___

!ERROR: too many actual arguments for intrinsic 'num_images'
!___ standard-conforming statements with team_type argument present ___
n = num_images(home)

!ERROR: unknown keyword argument to intrinsic 'num_images'
n = num_images(team=home)

!___ non-conforming statements ___
Expand Down

0 comments on commit 473d780

Please sign in to comment.