+
+ /* if extern then do nothing or is a function
+ then do nothing */
+ if (IS_FUNC (sym->type))
+ continue;
+
+ /* print extra debug info if required */
+ if (options.debug) {
+ cdbSymbol (sym, cdbFile, FALSE, FALSE);
+ if (!sym->level) /* global */
+ if (IS_STATIC (sym->etype))
+ fprintf (map->oFile, "F%s$", moduleName); /* scope is file */
+ else
+ fprintf (map->oFile, "G$"); /* scope is global */
+ else
+ /* symbol is local */
+ fprintf (map->oFile, "L%s$", (sym->localof ? sym->localof->name : "-null-"));
+ fprintf (map->oFile, "%s$%d$%d", sym->name, sym->level, sym->block);
+ }
+
+ /* if it has an initial value then do it only if
+ it is a global variable */
+ if (sym->ival && sym->level == 0) {
+ if (SPEC_OCLS(sym->etype)==xidata) {
+ // create a new "XINIT (CODE)" symbol, that will be emitted later
+ newSym=copySymbol (sym);
+ SPEC_OCLS(newSym->etype)=xinit;
+ sprintf (newSym->name, "_xinit_%s", sym->name);
+ sprintf (newSym->rname,"_xinit_%s", sym->rname);
+ SPEC_CONST(newSym->etype)=1;
+ //SPEC_STAT(newSym->etype)=1;
+ addSym (SymbolTab, newSym, newSym->name, 0, 0, 1);
+
+ // add it to the "XINIT (CODE)" segment
+ addSet(&xinit->syms, newSym);
+
+ //fprintf (stderr, "moved %s from xdata to xidata\n", sym->rname);
+
+ } else {
+ if (IS_AGGREGATE (sym->type)) {
+ ival = initAggregates (sym, sym->ival, NULL);
+ } else {
+ if (getNelements(sym->type, sym->ival)>1) {
+ werror (W_EXCESS_INITIALIZERS, "scalar",
+ sym->name, sym->lineDef);
+ }
+ ival = newNode ('=', newAst_VALUE (symbolVal (sym)),
+ decorateType (resolveSymbols (list2expr (sym->ival))));
+ }
+ codeOutFile = statsg->oFile;
+
+ if (ival) {
+ // set ival's lineno to where the symbol was defined
+ lineno=ival->lineno=sym->lineDef;
+
+ // check if this is a constant expression
+ if (constExprTree(ival->right)) {
+ allocInfo = 0;
+ eBBlockFromiCode (iCodeFromAst (ival));
+ allocInfo = 1;
+ } else {
+ werror (E_CONST_EXPECTED, "found expression");
+ }
+ }
+ }
+
+ /* if the ival is a symbol assigned to an aggregate,
+ (bug #458099 -> #462479)
+ we don't need it anymore, so delete it from its segment */
+ if (sym->ival->type == INIT_NODE &&
+ IS_AST_SYM_VALUE(sym->ival->init.node) &&
+ IS_AGGREGATE (sym->type) ) {
+ symIval=AST_SYMBOL(sym->ival->init.node);
+ segment = SPEC_OCLS (symIval->etype);
+ deleteSetItem (&segment->syms, symIval);