Issue 240423
Summary [flang] Missing diagnostic on MERGE with polymorphic TSOURCE and a nonpolymorphic FSOURCE as a SELECT TYPE selector
Labels flang:frontend
Assignees
Reporter DanielCChen
    Consider the following test case
```
program ex3911
  implicit none
  type :: base
    integer :: id = 1
  end type
  class(base), allocatable :: t
 type(base) :: f
  allocate(t)
  f = base(2)
  select type (r => merge(t, f, .false.))
  type is (base)
    print '(A,I0)', 'merge result is base, id = ', r%id
  end select
end program
```

Flang failed at lowering as
```
error: loc("a.f":10:3): 'fir.select_type' op selector must be polymorphic
error: verification of lowering to FIR failed
```

The code is not conforming as the standard says the result of `MERGE` is only polymorphic if both `TSOURCE` and `FSROUCE` are polymorphic. In this case, `FSOURCE` is not polymorphic. 

XLF supports this as an extension, but both gfortran and ifx issue a compile time error. 

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to