Remove warnings when compiling IL generated C code
authorlaurent
Mon, 19 Oct 2009 18:12:44 +0200
changeset 211 5249d313ff7c
parent 210 8387cac2aba6
child 212 8c9ec7d37d3a
Remove warnings when compiling IL generated C code
stage4/generate_c/generate_c_il.cc
--- a/stage4/generate_c/generate_c_il.cc	Mon Sep 21 12:04:15 2009 +0200
+++ b/stage4/generate_c/generate_c_il.cc	Mon Oct 19 18:12:44 2009 +0200
@@ -513,10 +513,25 @@
   s4o.print(IL_DEFVAR_T);
   s4o.print(" ");
   this->default_variable_name.accept(*this);
-  s4o.print(";\n\n");
+  s4o.print(";\n");
+  s4o.print(s4o.indent_spaces);
+  print_backup_variable();
+  s4o.print(".INTvar = 0;\n\n");
 
   print_list(symbol, s4o.indent_spaces, ";\n" + s4o.indent_spaces, ";\n");
 
+  /* label not used by at least one goto result in a warning.
+   * To work around this we introduce the useless goto
+   * to humour the compiler...
+   */
+  s4o.print("\n");
+  s4o.print(s4o.indent_spaces);
+  s4o.print("/* to humour the compiler, we insert a goto */\n");
+  s4o.print(s4o.indent_spaces);
+  s4o.print("goto ");
+  s4o.print(END_LABEL);
+  s4o.print(";\n");
+
   /* write the label marking the end of the code block */
   /* please see the comment before the RET_operator_c visitor for details... */
   s4o.print("\n");