Skip to content

[flang] PDT: Incorrect diagnostic on Length type parameter in PDT #167351

@DanielCChen

Description

@DanielCChen

Not sure if Flang frontend has full support of the Length type parameter of PDT. If not yet, I am happy to close this issue and mark the test case.

Consider the following code:

MODULE Mod
      IMPLICIT NONE

      TYPE :: Base(k1, l1)
        INTEGER, KIND :: k1 = 1
        INTEGER, LEN  :: l1 = 1

        INTEGER(k1)   :: A0(l1) = -1
        CHARACTER(l1) :: C0 = 'Base'
      END TYPE

      TYPE,  EXTENDS(Base)  :: Child(k2, l2)
        INTEGER(k1), KIND    :: k2 = k1
        INTEGER(k1), LEN     :: l2 = k1

        CHARACTER(l2+3) :: C1 = 'Child'
      END TYPE

      TYPE, EXTENDS(Child) :: NextGen(l3)
        INTEGER(k2), LEN     :: l3 = k2

        CHARACTER(l3)      :: C2 = CHAR(k2)
        INTEGER(k2)        :: A2 = k2
        TYPE(Base(k2, l3)) :: cmp
        CLASS(Base(k2, l3)), POINTER  :: ptr
      END TYPE

      CONTAINS

      SUBROUTINE CheckNextGen(Obj,Arg)
         CLASS(NextGen(4,*,4,*,*)) :: Obj
         TYPE (NextGen(4,*,4,*,*)) :: Arg

      END SUBROUTINE

END MODULE

Flang issues a set of error messages starting at

error: Semantic errors in t.f
./t.f:8:26: error: Shape of initialized object 'a0' must be constant
          INTEGER(k1)   :: A0(l1) = -1
                           ^^
./t.f:31:10: in the context: instantiation of parameterized derived type 'base(k1=4_4,l1=*)'
           CLASS(NextGen(4,*,4,*,*)) :: Obj
....
.....

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions