[PATCH] D113077: [flang] Add a semantics test for co_min

Damian Rouson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 1 15:24:24 PST 2021


rouson updated this revision to Diff 391150.

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

https://reviews.llvm.org/D113077

Files:
  flang/test/Semantics/collectives02.f90


Index: flang/test/Semantics/collectives02.f90
===================================================================
--- /dev/null
+++ flang/test/Semantics/collectives02.f90
@@ -0,0 +1,64 @@
+! RUN: %python %S/test_errors.py %s %flang_fc1
+! XFAIL: *
+! This test checks for semantic errors in co_min() subroutine calls based on
+! the co_min interface defined in section 16.9.48 of the Fortran 2018 standard.
+! To Do: add co_min to the evaluation stage
+
+program main
+  implicit none
+
+  integer i, status
+  real vector(1)
+  real coindexed[*]
+  real array(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1,1,1)
+  character(len=1) string, message
+
+  complex complex_type
+  logical logical_type
+  type derived_t
+  end type
+  type(derived_t) derived_type
+
+  ! correct calls, should produce no errors
+  call co_min(i)
+  call co_min(i,   1)
+  call co_min(i,   1,              status)
+  call co_min(i,   1,              stat=status)
+  call co_min(i,   1,                           errmsg=message)
+  call co_min(i,   1,              stat=status, errmsg=message)
+  call co_min(i,   result_image=1, stat=status, errmsg=message)
+  call co_min(a=i, result_image=1, stat=status, errmsg=message)
+
+  call co_min(array,  result_image=1, stat=status, errmsg=message)
+  call co_min(vector, result_image=1, stat=status, errmsg=message)
+  call co_min(string, result_image=1, stat=status, errmsg=message)
+
+  ! incorrect type for the first argument
+  !ERROR: Actual argument for 'a=' has bad type 'LOGICAL(4)'
+  call co_min(logical_type, 1)
+
+  ! incorrect type for the first argument
+  !ERROR: Actual argument for 'a=' has bad type 'COMPLEX(4)'
+  call co_min(complex_type, 1)
+
+  ! incorrect type for the first argument
+  !ERROR: Actual argument for 'a=' has bad type 'derived_t'
+  call co_min(derived_type, 1)
+
+  ! incorrect type for the stat= argument
+  !ERROR: Actual argument for 'stat=' has bad type 'CHARACTER(KIND=1,LEN=1_8)'
+  call co_min(i, 1, message)
+
+  ! too many arguments to the co_min() call
+  !ERROR: too many actual arguments for intrinsic 'co_min'
+  call co_min(i,   result_image=1, stat=status, errmsg=message, 3.4)
+
+  ! keyword argument with incorrect type
+  !ERROR: unknown keyword argument to intrinsic 'co_min'
+  call co_min(fake=3.4)
+
+  ! the standard prohibits coindexed arguments in co_min
+  !ERROR: (message to be determined)
+  call co_min(coindexed[1])
+
+end program


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113077.391150.patch
Type: text/x-patch
Size: 2408 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211201/936f93ae/attachment.bin>


More information about the llvm-commits mailing list