Skip to content

Commit b53bdc6

Browse files
authored
[flang] Add default component initialization to some built-in types (#121416)
The standard requires EVENT_TYPE, LOCK_TYPE, NOTIFY_TYPE, and TEAM_TYPE to have full default initialization for their nonallocatable private components.
1 parent 07b3bba commit b53bdc6

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

flang/module/__fortran_builtins.f90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@
4343
end type
4444

4545
type, public :: __builtin_event_type
46-
integer(kind=int64), private :: __count
46+
integer(kind=int64), private :: __count = -1
4747
end type
4848

4949
type, public :: __builtin_notify_type
50-
integer(kind=int64), private :: __count
50+
integer(kind=int64), private :: __count = -1
5151
end type
5252

5353
type, public :: __builtin_lock_type
54-
integer(kind=int64), private :: __count
54+
integer(kind=int64), private :: __count = -1
5555
end type
5656

5757
type, public :: __builtin_ieee_flag_type
@@ -91,7 +91,7 @@
9191
__builtin_ieee_round_type(_FORTRAN_RUNTIME_IEEE_OTHER)
9292

9393
type, public :: __builtin_team_type
94-
integer(kind=int64), private :: __id
94+
integer(kind=int64), private :: __id = -1
9595
end type
9696

9797
integer, parameter, public :: __builtin_atomic_int_kind = selected_int_kind(18)

flang/test/Semantics/get_team.f90

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ program get_team_test
1010
type(team_type) :: result_team
1111
logical wrong_result_type, non_integer
1212

13+
result_team = team_type()
14+
1315
!___ standard-conforming statement with no optional arguments present ___
1416
result_team = get_team()
1517

0 commit comments

Comments
 (0)