[flang-commits] [flang] b53bdc6 - [flang] Add default component initialization to some built-in types (#121416)

via flang-commits flang-commits at lists.llvm.org
Wed Jan 8 13:14:31 PST 2025


Author: Peter Klausler
Date: 2025-01-08T13:14:28-08:00
New Revision: b53bdc61013a4349283baa3eb21434f4f88b66d1

URL: https://github.com/llvm/llvm-project/commit/b53bdc61013a4349283baa3eb21434f4f88b66d1
DIFF: https://github.com/llvm/llvm-project/commit/b53bdc61013a4349283baa3eb21434f4f88b66d1.diff

LOG: [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.

Added: 
    

Modified: 
    flang/module/__fortran_builtins.f90
    flang/test/Semantics/get_team.f90

Removed: 
    


################################################################################
diff  --git a/flang/module/__fortran_builtins.f90 b/flang/module/__fortran_builtins.f90
index ab12d6c3089c59..4d134fa4b62b13 100644
--- a/flang/module/__fortran_builtins.f90
+++ b/flang/module/__fortran_builtins.f90
@@ -43,15 +43,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
@@ -91,7 +91,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()
 


        


More information about the flang-commits mailing list