]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Always add default label to switch statements
authorJürg Billeter <j@bitron.ch>
Thu, 13 Jan 2011 06:19:32 +0000 (07:19 +0100)
committerJürg Billeter <j@bitron.ch>
Thu, 13 Jan 2011 06:19:32 +0000 (07:19 +0100)
codegen/valaccodecontrolflowmodule.vala

index 6e7ac1323c8646e5a6daddb93693184932195bd2..30bb83de70938a7a226f6f7b06cfa9573ed7b36d 100644 (file)
@@ -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 ();
        }