<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/102557>102557</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Flang] Compilation error of component-data-source in structure constructor
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            flang:frontend
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ohno-fj
      </td>
    </tr>
</table>

<pre>
    ```
Version of flang-new : 20.0.0(8dd065d5bc81b0c8ab57f365bb169a5d92928f25)/AArch64
```

The following program for `component-data-source` in `structure constructor` results in a compilation-time error.  
When `module` is expanded into the `subroutine`, the compilation is successful.  
The fixed program is `snggp555_22.f90`.


The following are the test program, Flang-new, Gfortran and ifort compilation/execution result.

snggp555_2.f90:
```fortran
module m1
  type a1
 integer ::x1=1
  end type a1
  type,extends(a1)::a2
     integer ::x2=3
  end type a2
  type,extends(a2)::a3
     integer ::x3=3
  end type a3
  type (a3),save:: v
end module m1

subroutine s1
  use m1
  v=a3(a1(x1=18),x2=6,x3=6)
end subroutine s1

program main
  call s1
  print *,'pass'
end program main
```

```
$ flang-new snggp555_2.f90
error: Semantic errors in snggp555_2.f90
./snggp555_2.f90:16:8: error: Value in structure constructor of type 'a1' is incompatible with component 'x1' of type 'INTEGER(4)'
    v=a3(a1(x1=18),x2=6,x3=6)
 ^^^^^^^^^
./snggp555_2.f90:3:16: Declaration of 'x1'
       integer ::x1=1
                 ^^
$
```

```
$ gfortran snggp555_2.f90; ./a.out
 pass
$
```

```
$ ifort -diag-disable=10448 snggp555_2.f90
snggp555_2.f90(16): error #8001: The type of the component in a structure-constructor differs from the type of the component in the derived-type-def.
 v=a3(a1(x1=18),x2=6,x3=6)
-------^
compilation aborted for snggp555_2.f90 (code 1)
$
```

snggp555_22.f90:
```fortran
subroutine s1
 type a1
     integer ::x1=1
  end type a1
  type,extends(a1)::a2
 integer ::x2=3
  end type a2
  type,extends(a2)::a3
     integer ::x3=3
  end type a3
  type (a3),save:: v
 v=a3(a1(x1=18),x2=6,x3=6)
end subroutine s1

program main
  call s1
  print *,'pass'
end program main
```

```
$ flang-new snggp555_22.f90; ./a.out
 pass
$
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcVk2P4ygT_jXkghzhcvx1yCHTmYzey3vYHc0eV9iUHUYORIDTmX-_AvLhdie9Uu9pN4oSg4unqKqnHuDWyl4hrkn-heTbBR_dXpu13iuddD8XjRa_1qRgly_bErb5gcZKrajuaDdw1ScKXynJNhTYki0ZgaoSghW5yJu2ShvWVrzJyy4r8qZJi5rnooYaqg5yAjWB3WZj2n2xiuAzX_H3-x5pp4dBv0rV06PRveEH2mlDScFafThqhcolgjueWD2aFknBqFT-tXVmbN1okLZaxYE2_rVBOw7OejNOPYgcuJNaJU4ekKIx2iwpjRv4Y48B7KDFOERwS_F85EqgoFI5Td0eg7uxMXp0UnkrAi9hfoLuF9qxbdHabhxuDkKE8oziFp20AU71_THP8z8Bll3t87KcJuZRerjB4NShdVc0v5HdtVZ-8K3TxhmuKFeCSj-YbpLADs_YjmHDMU9v3N53FTaVbWa1u4DH2ZgzekjjkFL364iUX4dSOezReAKRbHNOSba9WaISM-swJPCCZ4dKWAIVTz2LwmIOVytK57hAsm32Hhee48IdN3uOmz3Gzd4E6-GyQPYXy08Yl9JTtPGLZjm6ZPlGJWpv8Y92msoTybYeOWShismroqMQceEfsvhQ3909QI6_V_IduFRXHy0fhskGjkYqRwlsCLwQKI_cWgLlHfs9xMOWnk_CaiImM35FbN-QPm2_44ErJ9vYoqF_H9kvCeze8TQtSLapPMoN7gcfRgwgj4TCi9ylhKXPcen7UirfK9zJZkD6Kt2e3jTI252D3WTh__7__eu3r78RqFahNuWdTp8oICX516ff56Fn1_DpFtuBm6hGurvteMLxdyx_05Wzz9QzgY9k_EHN-6sOzff7hfoo-FKP7uI3MO1zXqLAJULyPhHS8mZAHxBb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