From 9dd3965e96d1f31f0d9303d503bbd12129cfe92b Mon Sep 17 00:00:00 2001 From: Craig Rasmussen Date: Mon, 4 Oct 2021 12:34:14 -0700 Subject: [PATCH] [flang] Added tests for intrinsic function 'team_number()' reviewers: klausler, PeteSteinfeld Differential Revision: https://reviews.llvm.org/D100897 --- flang/docs/Intrinsics.md | 2 +- flang/test/Semantics/team_number.f90 | 22 ++++++++++++++++++++++ flang/unittests/Evaluate/intrinsics.cpp | 24 ++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 flang/test/Semantics/team_number.f90 diff --git a/flang/docs/Intrinsics.md b/flang/docs/Intrinsics.md index f8f335f9d4da..d5fdee8f4ff7 100644 --- a/flang/docs/Intrinsics.md +++ b/flang/docs/Intrinsics.md @@ -746,7 +746,7 @@ This phase currently supports all the intrinsic procedures listed above but the | 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 | diff --git a/flang/test/Semantics/team_number.f90 b/flang/test/Semantics/team_number.f90 new file mode 100644 index 000000000000..fc489cca463d --- /dev/null +++ b/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 diff --git a/flang/unittests/Evaluate/intrinsics.cpp b/flang/unittests/Evaluate/intrinsics.cpp index dd1a8a5a8f0e..45e47afd6e65 100644 --- a/flang/unittests/Evaluate/intrinsics.cpp +++ b/flang/unittests/Evaluate/intrinsics.cpp @@ -294,6 +294,30 @@ void TestIntrinsics() { .Push(Const(Scalar{})) .DoCall(); // bad type + TestCall{defaults, table, "team_number"}.DoCall(Int4::GetType()); + TestCall{defaults, table, "team_number"} + .Push(Const(Scalar{})) + .Push(Const(Scalar{})) + .DoCall(); // too many args + TestCall{defaults, table, "team_number"} + .Push(Named("bad", Const(Scalar{}))) + .DoCall(); // bad keyword + TestCall{defaults, table, "team_number"} + .Push(Const(Scalar{})) + .DoCall(); // bad type + TestCall{defaults, table, "team_number"} + .Push(Const(Scalar{})) + .DoCall(); // bad type + TestCall{defaults, table, "team_number"} + .Push(Const(Scalar{})) + .DoCall(); // bad type + TestCall{defaults, table, "team_number"} + .Push(Const(Scalar{})) + .DoCall(); // bad type + TestCall{defaults, table, "team_number"} + .Push(Const(Scalar{})) + .DoCall(); // bad type + // TODO: test other intrinsics // Test unrestricted specific to generic name mapping (table 16.2).