[PATCH] D100897: [flang] Make 'team_number()' an intrinsic function

Craig E Rasmussen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 29 21:57:06 PDT 2021


craig.rasmussen updated this revision to Diff 376100.
craig.rasmussen added a comment.

Update based on changes in https://reviews.llvm.org/D110356.  Cleaned up tests.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100897/new/

https://reviews.llvm.org/D100897

Files:
  flang/docs/Intrinsics.md
  flang/test/Semantics/team_number.f90
  flang/unittests/Evaluate/intrinsics.cpp


Index: flang/unittests/Evaluate/intrinsics.cpp
===================================================================
--- flang/unittests/Evaluate/intrinsics.cpp
+++ flang/unittests/Evaluate/intrinsics.cpp
@@ -294,6 +294,30 @@
       .Push(Const(Scalar<Real4>{}))
       .DoCall(); // bad type
 
+  TestCall{defaults, table, "team_number"}.DoCall(Int4::GetType());
+  TestCall{defaults, table, "team_number"}
+      .Push(Const(Scalar<Int4>{}))
+      .Push(Const(Scalar<Int4>{}))
+      .DoCall(); // too many args
+  TestCall{defaults, table, "team_number"}
+      .Push(Named("bad", Const(Scalar<Int4>{})))
+      .DoCall(); // bad keyword
+  TestCall{defaults, table, "team_number"}
+      .Push(Const(Scalar<Int4>{}))
+      .DoCall(); // bad type
+  TestCall{defaults, table, "team_number"}
+      .Push(Const(Scalar<Char>{}))
+      .DoCall(); // bad type
+  TestCall{defaults, table, "team_number"}
+      .Push(Const(Scalar<Log4>{}))
+      .DoCall(); // bad type
+  TestCall{defaults, table, "team_number"}
+      .Push(Const(Scalar<Complex8>{}))
+      .DoCall(); // bad type
+  TestCall{defaults, table, "team_number"}
+      .Push(Const(Scalar<Real4>{}))
+      .DoCall(); // bad type
+
   // TODO: test other intrinsics
 
   // Test unrestricted specific to generic name mapping (table 16.2).
Index: flang/test/Semantics/team_number.f90
===================================================================
--- /dev/null
+++ flang/test/Semantics/team_number.f90
@@ -0,0 +1,22 @@
+! RUN: %python %S/test_errors.py %s %flang_fc1
+! Check for semantic errors in team_number() function calls
+
+subroutine test
+  use, intrinsic :: iso_fortran_env, only: team_type
+  type(team_type) :: team
+
+  ! correct calls, should produce no errors
+  team = get_team()
+  print *, team_number()
+  print *, team_number(team)
+  print *, team_number(team=team)
+
+  ! call with too many arguments
+  !ERROR: too many actual arguments for intrinsic 'team_number'
+  print *, team_number(1, 3)
+
+  ! keyword argument with incorrect type
+  !ERROR: Actual argument for 'team=' has bad type 'REAL(4)'
+  print *, team_number(team=3.1415)
+
+end subroutine
Index: flang/docs/Intrinsics.md
===================================================================
--- flang/docs/Intrinsics.md
+++ flang/docs/Intrinsics.md
@@ -746,7 +746,7 @@
 
 | Intrinsic Category | Intrinsic Procedures Lacking Support |
 | --- | --- |
-| Coarray intrinsic functions | LCOBOUND, UCOBOUND, FAILED_IMAGES, GET_TEAM, IMAGE_INDEX, STOPPED_IMAGES, TEAM_NUMBER, COSHAPE |
+| Coarray intrinsic functions | LCOBOUND, UCOBOUND, FAILED_IMAGES, IMAGE_INDEX, STOPPED_IMAGES, COSHAPE |
 | Object characteristic inquiry functions | ALLOCATED, ASSOCIATED, EXTENDS_TYPE_OF, IS_CONTIGUOUS, PRESENT, RANK, SAME_TYPE, STORAGE_SIZE |
 | Type inquiry intrinsic functions | BIT_SIZE, DIGITS, EPSILON, HUGE, KIND, MAXEXPONENT, MINEXPONENT, NEW_LINE, PRECISION, RADIX, RANGE, TINY|
 | Non-standard intrinsic functions | AND, OR, XOR, LSHIFT, RSHIFT, SHIFT, ZEXT, IZEXT, COSD, SIND, TAND, ACOSD, ASIND, ATAND, ATAN2D, COMPL, DCMPLX, EQV, NEQV, INT8, JINT, JNINT, KNINT, LOC, QCMPLX, DREAL, DFLOAT, QEXT, QFLOAT, QREAL, DNUM, NUM, JNUM, KNUM, QNUM, RNUM, RAN, RANF, ILEN, SIZEOF, MCLOCK, SECNDS, COTAN, IBCHNG, ISHA, ISHC, ISHL, IXOR, IARG, IARGC, NARGS, NUMARG, BADDRESS, IADDR, CACHESIZE, EOF, FP_CLASS, INT_PTR_KIND, ISNAN, MALLOC |


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100897.376100.patch
Type: text/x-patch
Size: 3380 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210930/9badc670/attachment.bin>


More information about the llvm-commits mailing list