Issue 153220
Summary [flang] [FORALL] Incorrect dynamic type assigned within FORALL
Labels flang:frontend
Assignees
Reporter DanielCChen
    Consider the following reducer:
```
  PROGRAM main
  IMPLICIT NONE
  TYPE :: DT
 CLASS(DT), POINTER    :: Ptr(:) => NULL()
  END TYPE

  TYPE, EXTENDS(DT) :: DT1
  END TYPE

  TYPE(DT1), TARGET  :: Tar1(100)
 CLASS(DT), POINTER :: T(:)
  integer :: I

  ALLOCATE(T(10))

  !DO I = 1, 10
  FORALL (I=1:10)            !! Wrong dynamic type assigned to T(I)%Ptr.
    T(I)%Ptr => Tar1
  END FORALL
  !end do

  DO I = 1, 10
 SELECT TYPE (aa => T(I)%Ptr)
    TYPE IS (DT1)
      print*, "in type is"
    CLASS DEFAULT
      print*, "in class default"
    END SELECT
 END DO

  END
```

Flang outputs 
```
> a.out
 in class default
 in class default
 in class default
 in class default
 in class default
 in class default
 in class default
 in class default
 in class default
 in class default
```

The expected output is
```
> a.out
 in type is
 in type is
 in type is
 in type is
 in type is
 in type is
 in type is
 in type is
 in type is
 in type is
```

If I replace `FORALL` with the `DO` loop, Flang executes successfully.

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to