[flang-commits] [flang] [flang] Fix NOTIFY= placement checking and folding (PR #231660)

Jean-Didier PAILLEUX via flang-commits flang-commits at lists.llvm.org
Wed Oct 14 04:34:21 PDT 2026


================
@@ -0,0 +1,171 @@
+! RUN: %python %S/test_errors.py %s %flang_fc1 -fopenmp -fopenmp-version=51 -fopenacc
+! F2023 C933
+
+module notify_defined_assignment
+  type t
+    integer :: value
+    integer :: values(4)
+  end type
+  interface assignment(=)
+    module procedure assign_integer
+  end interface
+contains
+  subroutine assign_integer(lhs, rhs)
+    type(t), intent(out) :: lhs
+    integer, intent(in) :: rhs
+    lhs%value = rhs
+  end subroutine
+  subroutine host_associated_assignment
+    use iso_fortran_env, only: notify_type
+    type(t), save :: d[*]
+    type(notify_type), save :: n[*]
+    !ERROR: NOTIFY= may appear only in the image selector of the variable of an intrinsic assignment statement
+    d[1, notify=n] = 1
+  end subroutine
+end module
+
+module notify_type_bound_assignment
+  type t
+    integer :: value
+  contains
+    procedure :: assign_integer
+    generic :: assignment(=) => assign_integer
+  end type
+contains
+  subroutine assign_integer(lhs, rhs)
+    class(t), intent(out) :: lhs
+    integer, intent(in) :: rhs
+    lhs%value = rhs
+  end subroutine
+end module
+
+program invalid_notify_contexts
+  use iso_fortran_env, only: notify_type, event_type, team_type
+  use notify_defined_assignment
+  use notify_type_bound_assignment, only: bound_t => t
+  implicit none
+  integer, target :: a(4)[*], b[*], local(4)
+  integer :: i
+  integer, pointer :: q, qa(:)
+  type(event_type) :: e[*]
+  type(notify_type) :: n[*], na(4)[*]
+  type(team_type) :: teams(4)
+  character(8) :: text[*]
+  type(t) :: d[*]
+  type(bound_t) :: bound_d[*]
+
+  !ERROR: NOTIFY= may appear only in the image selector of the variable of an intrinsic assignment statement
+  event post(e[1, notify=n])
+  !ERROR: NOTIFY= may appear only in the image selector of the variable of an intrinsic assignment statement
+  b = a(1)[1, notify=n]
+  !ERROR: NOTIFY= may appear only in the image selector of the variable of an intrinsic assignment statement
+  call consume(a(1)[1, notify=n])
+  !ERROR: NOTIFY= may appear only in the image selector of the variable of an intrinsic assignment statement
+  print *, a(1)[1, notify=n]
+  !ERROR: NOTIFY= may appear only in the image selector of the variable of an intrinsic assignment statement
+  a(1)[1, notify=n] = a(2)[1, notify=n]
+  !ERROR: A coindexed object may not be a pointer target
+  !ERROR: NOTIFY= may appear only in the image selector of the variable of an intrinsic assignment statement
+  q => a(1)[1, notify=n]
+  !ERROR: NOTIFY= may appear only in the image selector of the variable of an intrinsic assignment statement
+  qa(a(1)[1, notify=n]:) => local
+  !ERROR: NOTIFY= may appear only in the image selector of the variable of an intrinsic assignment statement
+  d[1, notify=n] = 1
+  !ERROR: NOTIFY= may appear only in the image selector of the variable of an intrinsic assignment statement
+  bound_d[1, notify=n] = 1
+  !ERROR: NOTIFY= may appear only in the image selector of the variable of an intrinsic assignment statement
+  where (a(:)[1, notify=n] > 0) a(:)[1] = 1
+  !ERROR: NOTIFY= may appear only in the image selector of the variable of an intrinsic assignment statement
+  forall (i=1:a(1)[1, notify=n]) a(i)[1] = 1
+  a(1)[1, notify=n] = 1
----------------
JDPailleux wrote:

Exactly, that's the only valid one, and I think it's necessary to have it. 
But, I agree that it should be moved to the beginning of the file.

https://github.com/llvm/llvm-project/pull/231660


More information about the flang-commits mailing list