From dc47767ba49232210db776d4e0b002a68992b715 Mon Sep 17 00:00:00 2001 From: Adrien Guatto Date: Fri, 12 Jun 2015 17:49:59 +0200 Subject: [PATCH] Print an empty default statement at the end of all C switches This prevents modern compilers from emitting warnings when the generated C code contains switch statements with (intentionally) missing cases. --- compiler/obc/c/c.ml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/obc/c/c.ml b/compiler/obc/c/c.ml index f7ae58f..b3b5a5d 100644 --- a/compiler/obc/c/c.ml +++ b/compiler/obc/c/c.ml @@ -238,7 +238,8 @@ and pp_cstm fmt stm = match stm with let pp_clause fmt (tag, stml) = fprintf fmt "@[case %a:%a@ break;@]" pp_cexpr (Cconst (Ctag tag)) pp_cstm_list stml in - fprintf fmt "@[@[switch (%a) {%a@]@ }@]" + fprintf fmt + "@[@[switch (%a) {%a@ @[default:@ break;@]@]@ }@]" pp_cexpr e (pp_list pp_clause "") cl | Caffect (lhs, e) -> fprintf fmt "%a = %a" pp_clhs lhs pp_cexpr e