From 632f1a5f12ffbb4aeeca933b8cde7d964b29b0b0 Mon Sep 17 00:00:00 2001 From: Andre Maroneze <andre.maroneze@cea.fr> Date: Mon, 4 Nov 2024 18:10:57 +0100 Subject: [PATCH] [kernel] fix printing of empty initializers for empty unions --- src/kernel_services/ast_printing/cil_printer.ml | 2 +- tests/syntax/empty_union.i | 2 +- tests/syntax/oracle/empty_union.0.res.oracle | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/kernel_services/ast_printing/cil_printer.ml b/src/kernel_services/ast_printing/cil_printer.ml index a229b8c217..88f336d80a 100644 --- a/src/kernel_services/ast_printing/cil_printer.ml +++ b/src/kernel_services/ast_printing/cil_printer.ml @@ -911,7 +911,7 @@ class cil_printer () = object (self) | _ -> Kernel.fatal "Trying to print malformed initializer" in if not (Cil.isArrayType t) then - Pretty_utils.pp_list ~pre:"{@[<hv>" ~sep:",@ " ~suf:"@]}" + Pretty_utils.pp_list ~pre:"{@[<hv>" ~sep:",@ " ~suf:"@]}" ~empty:"{}" designated_init fmt initl else begin let print_index prev_index (designator,init as di) = diff --git a/tests/syntax/empty_union.i b/tests/syntax/empty_union.i index e941af4a43..e6a8d86207 100644 --- a/tests/syntax/empty_union.i +++ b/tests/syntax/empty_union.i @@ -1,5 +1,5 @@ /* run.config* - STDOPT: +"-machdep gcc_x86_32" + STDOPT: +"-machdep gcc_x86_32 -print -ocode @PTEST_NAME@_reparse.c -then @PTEST_NAME@_reparse.c -ocode=''" EXIT: 1 STDOPT: */ diff --git a/tests/syntax/oracle/empty_union.0.res.oracle b/tests/syntax/oracle/empty_union.0.res.oracle index d977ab5bcc..7d386369f1 100644 --- a/tests/syntax/oracle/empty_union.0.res.oracle +++ b/tests/syntax/oracle/empty_union.0.res.oracle @@ -1,7 +1,8 @@ [kernel] Parsing empty_union.i (no preprocessing) +[kernel] Parsing empty_union_reparse.c (with preprocessing) /* Generated by Frama-C */ union empty { }; -union empty eu = ; +union empty eu = {}; -- GitLab