[flang-commits] [flang] c1becf4 - [flang] Add a semantics test for co_sum

Damian Rouson via flang-commits flang-commits at lists.llvm.org
Wed Nov 17 16:39:00 PST 2021


Author: Damian Rouson
Date: 2021-11-17T16:37:00-08:00
New Revision: c1becf483c9f00b9465a999766a1505e2f4ea0be

URL: https://github.com/llvm/llvm-project/commit/c1becf483c9f00b9465a999766a1505e2f4ea0be
DIFF: https://github.com/llvm/llvm-project/commit/c1becf483c9f00b9465a999766a1505e2f4ea0be.diff

LOG: [flang] Add a semantics test for co_sum

Test a range of acceptable forms of co_sum calls, including
combinations of keyword and non-keyword actual arguments of
numeric types.  Also test that several invalid forms of
co_sum call generate the correct error messages.

Reviewed By: kiranchandramohan, ktras

Differential Revision: https://reviews.llvm.org/D113076

Added: 
    flang/test/Semantics/collectives01.f90

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/flang/test/Semantics/collectives01.f90 b/flang/test/Semantics/collectives01.f90
new file mode 100644
index 0000000000000..cd293bf525875
--- /dev/null
+++ b/flang/test/Semantics/collectives01.f90
@@ -0,0 +1,46 @@
+! RUN: %python %S/test_errors.py %s %flang_fc1
+! XFAIL: *
+! Check for semantic errors in co_sum() subroutine calls
+! To Do: add co_sum to the evaluation stage
+
+module test_co_sum
+  implicit none
+
+contains
+
+  subroutine test
+  
+    integer i, status
+    real array(1)
+    complex z(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1,1,1) 
+    character(len=1) message
+  
+    ! correct calls, should produce no errors
+    call co_sum(i)
+    call co_sum(i,   1)
+    call co_sum(i,   1,              status)
+    call co_sum(i,   1,              stat=status)
+    call co_sum(i,   1,                           errmsg=message)
+    call co_sum(i,   1,              stat=status, errmsg=message)
+    call co_sum(i,   result_image=1, stat=status, errmsg=message)
+    call co_sum(a=i, result_image=1, stat=status, errmsg=message)
+    call co_sum(i,   result_image=1, stat=status, errmsg=message)
+  
+    call co_sum(array, result_image=1, stat=status, errmsg=message)
+    call co_sum(z, result_image=1, stat=status, errmsg=message)
+ 
+    ! the error is seen as an incorrect type for the stat= argument
+    !ERROR: Actual argument for 'stat=' has bad type 'CHARACTER(KIND=1,LEN=1_8)'
+    call co_sum(i, 1, message)
+ 
+    ! the error is seen as too many arguments to the co_sum() call
+    !ERROR: too many actual arguments for intrinsic 'co_sum'
+    call co_sum(i,   result_image=1, stat=status, errmsg=message, 3.4)
+  
+    ! keyword argument with incorrect type
+    !ERROR: unknown keyword argument to intrinsic 'co_sum'
+    call co_sum(fake=3.4)
+  
+  end subroutine
+
+end module test_co_sum


        


More information about the flang-commits mailing list