Fix bug in code generation of directly declared array variables that generate wrong code when using located variables in a program POU
--- a/stage4/generate_c/generate_c.cc Sun Oct 09 20:16:41 2011 +0200
+++ b/stage4/generate_c/generate_c.cc Sun Oct 09 20:18:55 2011 +0200
@@ -868,7 +868,12 @@
/* variable_name -> may be NULL ! */
//SYM_REF4(located_var_decl_c, variable_name, location, located_var_spec_init, unused)
void *visit(located_var_decl_c *symbol) {
- symbol->located_var_spec_init->accept(*this);
+ array_spec_init_c* array_spec_init = dynamic_cast<array_spec_init_c*>(symbol->located_var_spec_init);
+ if (array_spec_init != NULL) {
+ current_mode = arrayname_im;
+ symbol->located_var_spec_init->accept(*this);
+ current_mode = none_im;
+ }
return NULL;
}