[flang-commits] [flang] [flang] Rework component KIND= values in PDT instantiations (PR #162367)

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Wed Oct 8 13:19:38 PDT 2025


klausler wrote:

> But referencing `i1%kind` is fine as
> 
> ```
>    type base
>      character(2) :: c1
>      integer(2) :: i1
>      character(i1%kind) :: c2
>      character(c1%len) :: c3
>    end type
>    type(base) :: b1
>    print*, b1%c1%len
>    print*, b1%c2%len
>    print*, b1%c3%len
> end
> ```
> 
> Also, it seems the `b1%c2%len` is wrong.
> 
> It should be `2` but Flang outputs `4`.

The `i1` in the expression`i1%kind` refers to an implicitly typed variable in the enclosing scope.  Put `IMPLICIT NONE` into your test and read the error messages.

You keep trying to use the names of components in expressions in a derived type definition.  That is not allowed.  Only type parameters and names from the enclosing scope can be used.

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


More information about the flang-commits mailing list