From 7d2a05a2322267092d6ed0801d9ec26699ac4313 Mon Sep 17 00:00:00 2001
From: Benjamin Jorge <benjamin.jorge@cea.fr>
Date: Thu, 26 Sep 2024 17:10:11 +0200
Subject: [PATCH] [cabs2cil] accept empty unions with correct machdeps

---
 src/kernel_internals/typing/cabs2cil.ml | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/kernel_internals/typing/cabs2cil.ml b/src/kernel_internals/typing/cabs2cil.ml
index 4ad7be278c..6c13294a50 100644
--- a/src/kernel_internals/typing/cabs2cil.ml
+++ b/src/kernel_internals/typing/cabs2cil.ml
@@ -3193,14 +3193,14 @@ let rec collectInitializer
         Cil_datatype.Typ.pretty thistype !pMaxIdx;
       (* Find the field to initialize *)
       let rec findField (idx: int) = function
-        | [] -> Kernel.fatal ~current:true "collectInitializer: union"
+        | [] -> [], reads
         | _ :: rest when idx < !pMaxIdx && !pArray.(idx) = NoInitPre ->
           findField (idx + 1) rest
         | f :: _ when idx = !pMaxIdx ->
           let init, reads =
             collectFieldInitializer reads !pArray.(idx) f ~parenttype:thistype
           in
-          (Field(f, NoOffset), init), reads
+          [ (Field(f, NoOffset), init) ], reads
 
         | _ ->
           abort_context "Can initialize only one field for union"
@@ -3209,7 +3209,7 @@ let rec collectInitializer
         Kernel.warning ~current:true
           "On MSVC we can initialize only the first field of a union";
       let init, reads = findField 0 (Option.value ~default:[] comp.cfields) in
-      CompoundInit (thistype, [ init ]), thistype, reads
+      CompoundInit (thistype, init), thistype, reads
 
     | _ -> Kernel.fatal ~current:true "collectInitializer"
 
-- 
GitLab