DREAL intrinsic

Currently, the DREAL intrinsic allows non-complex(8) argument. Other implementations (i.e. gfortran, ifx, xlf) only allow complex(8) as the actual argument. Is allowing non-complex(8) argument intentional in flang implementation?

$ cat dreal.f90
  complex(4) :: c
  real(4) :: x
  x = dreal(c)
end

$ gfortran dreal.f90
dreal.f90:3:10:

 x = dreal(c)
          1
Error: Type of argument 'a' in call to 'dreal' at (1) should be COMPLEX(8), not COMPLEX(4)

$ flang-new dreal.f90
$

This behavior is intentional.

From https://github.com/llvm/llvm-project/blob/main/flang/docs/Extensions.md:

  • Restricted specific conversion intrinsics FLOAT, SNGL, IDINT, IFIX, DREAL,
    and DCMPLX accept arguments of any kind instead of only the default kind or
    double precision kind. Their result kinds remain as specified.

Also from that document:

As a general principle, this compiler will accept by default and without complaint many legacy features, extensions to the standard language, and features that have been deleted from the standard, so long as the recognition of those features would not cause a standard-conforming program to be rejected or misinterpreted.

Thanks for the explanation. I will remove DREAL from the Intrinsic Procedures Lacking Support list if there is no objection.

https://flang.llvm.org/docs/Intrinsics.html#intrinsic-procedure-support-in-f18