1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic
!
! Error tests for structure constructors of derived types with allocatable components
module m
type parent1
integer, allocatable :: pa
end type parent1
type parent2
real, allocatable :: pa(:)
end type parent2
type child
integer :: i
type(parent2) :: ca
end type
contains
subroutine test1()
integer :: j
real :: arr(5)
integer, pointer :: ipp
real, pointer :: rpp(:)
!ERROR: Must be a constant value
type(parent1) :: tp1 = parent1(3)
!ERROR: Must be a constant value
type(parent1) :: tp2 = parent1(j)
type(parent1) :: tp3 = parent1(null())
!PORTABILITY: NULL() with arguments is not standard conforming as the value for allocatable component 'pa' [-Wnull-mold-allocatable-component-value]
type(parent1) :: tp4 = parent1(null(ipp))
!ERROR: Must be a constant value
type(parent2) :: tp5 = parent2([1.1,2.1,3.1])
!ERROR: Must be a constant value
type(parent2) :: tp6 = parent2(arr)
type(parent2) :: tp7 = parent2(null())
!PORTABILITY: NULL() with arguments is not standard conforming as the value for allocatable component 'pa' [-Wnull-mold-allocatable-component-value]
type(parent2) :: tp8 = parent2(null(rpp))
end subroutine test1
subroutine test2()
integer :: j
real :: arr(5)
integer, pointer :: ipp
real, pointer :: rpp(:)
type(parent1) :: tp1
type(parent2) :: tp2
tp1 = parent1(3)
tp1 = parent1(j)
tp1 = parent1(null())
!PORTABILITY: NULL() with arguments is not standard conforming as the value for allocatable component 'pa' [-Wnull-mold-allocatable-component-value]
tp1 = parent1(null(ipp))
tp2 = parent2([1.1,2.1,3.1])
tp2 = parent2(arr)
tp2 = parent2(null())
!PORTABILITY: NULL() with arguments is not standard conforming as the value for allocatable component 'pa' [-Wnull-mold-allocatable-component-value]
tp2 = parent2(null(rpp))
end subroutine test2
subroutine test3()
real, pointer :: pp(:)
type(child) :: tc1 = child(5, parent2(null()))
!PORTABILITY: NULL() with arguments is not standard conforming as the value for allocatable component 'pa' [-Wnull-mold-allocatable-component-value]
type(child) :: tc10 = child(5, parent2(null(pp)))
!ERROR: Must be a constant value
type(child) :: tc3 = child(5, parent2([1.1,1.2]))
type(child) :: tc4
tc4 = child(5, parent2(null()))
tc4 = child(5, parent2([1.1,1.2]))
end subroutine test3
end module m
|