[flang-commits] [flang] [flang] Add default component initialization to some built-in types (PR #121416)
via flang-commits
flang-commits at lists.llvm.org
Tue Dec 31 13:52:29 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-semantics
Author: Peter Klausler (klausler)
<details>
<summary>Changes</summary>
The standard requires EVENT_TYPE, LOCK_TYPE, NOTIFY_TYPE, and TEAM_TYPE to have full default initialization for their nonallocatable private components.
---
Full diff: https://github.com/llvm/llvm-project/pull/121416.diff
2 Files Affected:
- (modified) flang/module/__fortran_builtins.f90 (+4-4)
- (modified) flang/test/Semantics/get_team.f90 (+2)
``````````diff
diff --git a/flang/module/__fortran_builtins.f90 b/flang/module/__fortran_builtins.f90
index ef206dfd943102..503633489b5755 100644
--- a/flang/module/__fortran_builtins.f90
+++ b/flang/module/__fortran_builtins.f90
@@ -40,15 +40,15 @@
end type
type, public :: __builtin_event_type
- integer(kind=int64), private :: __count
+ integer(kind=int64), private :: __count = -1
end type
type, public :: __builtin_notify_type
- integer(kind=int64), private :: __count
+ integer(kind=int64), private :: __count = -1
end type
type, public :: __builtin_lock_type
- integer(kind=int64), private :: __count
+ integer(kind=int64), private :: __count = -1
end type
type, public :: __builtin_ieee_flag_type
@@ -88,7 +88,7 @@
__builtin_ieee_round_type(_FORTRAN_RUNTIME_IEEE_OTHER)
type, public :: __builtin_team_type
- integer(kind=int64), private :: __id
+ integer(kind=int64), private :: __id = -1
end type
integer, parameter, public :: __builtin_atomic_int_kind = selected_int_kind(18)
diff --git a/flang/test/Semantics/get_team.f90 b/flang/test/Semantics/get_team.f90
index 7e4886703d17c2..a5b49a83f95f5a 100644
--- a/flang/test/Semantics/get_team.f90
+++ b/flang/test/Semantics/get_team.f90
@@ -10,6 +10,8 @@ program get_team_test
type(team_type) :: result_team
logical wrong_result_type, non_integer
+ result_team = team_type()
+
!___ standard-conforming statement with no optional arguments present ___
result_team = get_team()
``````````
</details>
https://github.com/llvm/llvm-project/pull/121416
More information about the flang-commits
mailing list