Skip to content

[flang] Another issue in cp2k 2025.1 compilation #132435

@shivaramaarao

Description

@shivaramaarao

The issue is present in latest trunk
A reduced testcase from cp2k 2025.1 sources is below.

a1.F90:

MODULE mytypes
   TYPE mytype
      INTEGER :: snumber = -1
   END TYPE mytype
END MODULE mytypes

MODULE dcsrconversions
   USE mytypes, ONLY: mytype
   TYPE cmapping
      TYPE(mytype)                          :: brd_mat = mytype()
   END TYPE
   TYPE ctype
      TYPE(cmapping)  :: dmapping = cmapping()
   END TYPE ctype
   PUBLIC :: ctype
END MODULE dcsrconversions

MODULE dapi
   USE mytypes, ONLY: &
      prv_mytype => mytype
   TYPE mytype
      TYPE(prv_mytype), PRIVATE        :: prv = prv_mytype()
   END TYPE mytype
END MODULE dapi

MODULE cp_api
   USE dapi, ONLY: &
      mytype_prv => mytype

   TYPE mytype
      TYPE(mytype_prv), PRIVATE :: prv = mytype_prv()
   END TYPE mytype
END MODULE cp_api

MODULE ptypes
   USE dcsrconversions,  ONLY: myctype => ctype
   USE cp_api,           ONLY: mytype
   PUBLIC :: lenv
   TYPE lenv
      TYPE(myctype)     :: csr_p = myctype()
   END TYPE lenv
END MODULE ptypes

a2.F90:

MODULE dm
   USE ptypes,ONLY: lenv
END MODULE dm

following error is generated in flang compilation

shivaram@amd:~/tt3$ flang -c a1.F90
shivaram@amd:~/tt3$ flang -c a2.F90
error: Semantic errors in a2.F90
./ptypes.mod:12:56: error: Value in structure constructor of type 'mytype' is incompatible with component 'brd_mat' of type 'mytype'
  type(myctype)::csr_p=myctype(dmapping=cmapping(brd_mat=mytype(snumber=-1_4)))
                                                         ^^^^^^^^^^^^^^^^^^^^
././dcsrconversions.mod:6:15: Declaration of 'brd_mat'
  type(mytype)::brd_mat=mytype(snumber=-1_4)
                ^^^^^^^
./ptypes.mod:12:63: error: Keyword 'snumber=' does not name a component of derived type 'mytype'
  type(myctype)::csr_p=myctype(dmapping=cmapping(brd_mat=mytype(snumber=-1_4)))
                                                                ^^^^^^^

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions