[flang-commits] [flang] [flang] Rework component KIND= values in PDT instantiations (PR #162367)
Daniel Chen via flang-commits
flang-commits at lists.llvm.org
Wed Oct 8 13:02:13 PDT 2025
DanielCChen wrote:
> > The full test case of the reducer is indeed fixed. Thanks!
> > The following is for the LEN= parameter of the character type.
> > ```
> > type base
> > character(2) :: c1
> > integer(2) :: i1
> > character(kind(i1)) :: c2
> > character(len(c1)) :: c3
> > end type
> > type(base) :: b1
> > print*, b1%c1%len
> > print*, b1%c2%len
> > print*, b1%c3%len
> > end
> > ```
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > The expected output
> > ```
> > > a.out
> > 2
> > 2
> > 2
> > ```
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > But Flang failed to compile it.
> > Should I open a new issue?
>
> No; it's not valid Fortran. You can't refer to components in a derived type definition, only to type parameters and to the type itself.
The code is inquiring the length type parameter of component `c1` though, the same way to inquire the kind parameter of `i1`. Both are constant expression is this case.
https://github.com/llvm/llvm-project/pull/162367
More information about the flang-commits
mailing list