[flang] Add team_type to num_images intrinsic call
authorKatherine Rasmussen <ktrasmussn@gmail.com>
Tue, 31 May 2022 20:15:54 +0000 (13:15 -0700)
committerKatherine Rasmussen <ktrasmussn@gmail.com>
Tue, 14 Jun 2022 18:28:46 +0000 (11:28 -0700)
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

flang/lib/Evaluate/intrinsics.cpp
flang/test/Semantics/num_images01.f90
flang/test/Semantics/num_images02.f90

index 64aafe5..a341da2 100644 (file)
@@ -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",
index 03bd0f4..37f360b 100644 (file)
@@ -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
@@ -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
index 378bdc8..fb05264 100644 (file)
@@ -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 ___