From: Jürg Billeter Date: Thu, 13 Jan 2011 06:19:32 +0000 (+0100) Subject: codegen: Always add default label to switch statements X-Git-Tag: 0.11.4~32 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=375432cb2bc46e53c7323469dc3ddd838ace5c7c;p=thirdparty%2Fvala.git codegen: Always add default label to switch statements --- diff --git a/codegen/valaccodecontrolflowmodule.vala b/codegen/valaccodecontrolflowmodule.vala index 6e7ac1323..30bb83de7 100644 --- a/codegen/valaccodecontrolflowmodule.vala +++ b/codegen/valaccodecontrolflowmodule.vala @@ -172,13 +172,22 @@ public abstract class Vala.CCodeControlFlowModule : CCodeMethodModule { ccode.open_switch (get_cvalue (stmt.expression)); + bool has_default = false; + foreach (SwitchSection section in stmt.get_sections ()) { if (section.has_default_label ()) { ccode.add_default (); + has_default = true; } section.emit (this); } + if (!has_default) { + // silence C compiler + ccode.add_default (); + ccode.add_break (); + } + ccode.close (); }