[PATCH] D113084: [flang] Add a semantics test for co_broadcast

Damian Rouson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 2 22:56:05 PDT 2021


rouson created this revision.
rouson added reviewers: craig.rasmussen, ktras, pmccormick.
Herald added a reviewer: sscalpone.
Herald added a project: Flang.
rouson requested review of this revision.
Herald added a subscriber: jdoerfert.
Herald added a project: LLVM.

This patch checks for valid and invalid forms of calls to the collective subroutine co_broadcast.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113084

Files:
  flang/test/Semantics/co_broadcast.f90


Index: flang/test/Semantics/co_broadcast.f90
===================================================================
--- /dev/null
+++ flang/test/Semantics/co_broadcast.f90
@@ -0,0 +1,51 @@
+! RUN: %S/test_errors.sh %s %t %flang_fc1
+! REQUIRES: shell
+! Check for semantic errors in co_broadcast() function calls
+
+module test_co_broadcast
+  implicit none
+
+contains
+
+  subroutine test
+
+    type foo_t
+    end type
+  
+    type(foo_t) foo
+    type(foo_t) bar(1,1)
+    integer i, status
+    real vector(1)
+    real array(1,1,1, 1,1,1, 1,1,1, 1,1,1, 1,1,1)
+    character(len=1) string, message
+  
+    ! correct calls, should produce no errors
+    call co_broadcast(i,   1)
+    call co_broadcast(i,   1,              status)
+    call co_broadcast(i,   1,              stat=status)
+    call co_broadcast(i,   1,                           errmsg=message)
+    call co_broadcast(i,   1,              stat=status, errmsg=message)
+    call co_broadcast(i,   source_image=1, stat=status, errmsg=message)
+    call co_broadcast(a=i, source_image=1, stat=status, errmsg=message)
+
+    call co_broadcast(array,  source_image=1, stat=status, errmsg=message)
+    call co_broadcast(vector, source_image=1, stat=status, errmsg=message)
+    call co_broadcast(string, source_image=1, stat=status, errmsg=message)
+    call co_broadcast(foo,    source_image=1, stat=status, errmsg=message)
+    call co_broadcast(bar,    source_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_broadcast(i, 1, message)
+
+    ! the error is seen as too many arguments to the co_broadcast() call
+    !ERROR: too many actual arguments for collective subroutines 'co_broadcast'
+    call co_broadcast(i, source_image=1, stat=status, errmsg=message, 3.4)
+  
+    ! keyword argument with incorrect type
+    !ERROR: unknown keyword argument to intrinsic 'co_broadcast'
+    call co_broadcast(fake=3.4)
+  
+  end subroutine
+
+end module test_co_broadcast


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113084.384345.patch
Type: text/x-patch
Size: 2103 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211103/1fdf7a15/attachment.bin>


More information about the llvm-commits mailing list