@@ -541,7 +541,7 @@ AddInitializers(AST *seq, AST *ident, AST *expr, AST *basetype)
541541 AstReportDone (& saveinfo );
542542 return seq ;
543543 } else if (expr -> kind == AST_EXPRLIST ) {
544- expr = FixupInitList (basetype , expr );
544+ expr = FixupInitList (basetype , expr , true );
545545 if (IsArrayType (basetype )) {
546546 if (!IsConstExpr (basetype -> right )) {
547547 ERROR (ident , "Variable length arrays not supported yet" );
@@ -569,13 +569,14 @@ AddInitializers(AST *seq, AST *ident, AST *expr, AST *basetype)
569569 AST * decl ;
570570 AST * subident ;
571571 AST * curexpr ;
572- while (varlist && varlist -> kind == AST_LISTHOLDER ) {
572+ bool moreVars = true;
573+ while (varlist && varlist -> kind == AST_LISTHOLDER && moreVars ) {
573574 decl = varlist -> left ;
574575 varlist = varlist -> right ;
575576 if (decl && decl -> kind == AST_DECLARE_VAR ) {
576577 subtype = decl -> left ;
577578 decl = decl -> right ;
578- while (decl ) {
579+ while (decl && moreVars ) {
579580 if (decl -> kind == AST_LISTHOLDER ) {
580581 subident = decl -> left ;
581582 decl = decl -> right ;
@@ -594,6 +595,14 @@ AddInitializers(AST *seq, AST *ident, AST *expr, AST *basetype)
594595 } else {
595596 curexpr = AstInteger (0 );
596597 }
598+ if (curexpr && curexpr -> kind == AST_ASSIGN_INIT ) {
599+ subident = curexpr -> left ;
600+ curexpr = curexpr -> right ;
601+ if (curexpr && curexpr -> kind == AST_CAST ) {
602+ subtype = curexpr -> left ;
603+ }
604+ moreVars = false;
605+ }
597606 sub = NewAST (AST_METHODREF , ident , subident );
598607 seq = AddInitializers (seq , sub , curexpr , subtype );
599608 }
@@ -671,7 +680,7 @@ findLocalsAndDeclare(Function *func, AST *ast)
671680 if (ident -> kind == AST_ASSIGN ) {
672681 // check for x[] = {a, b, c} type initializers here
673682 if (IsArrayType (basetype ) && basetype -> right == NULL ) {
674- AST * tmp = FixupInitList (basetype , ident -> right );
683+ AST * tmp = FixupInitList (basetype , ident -> right , false );
675684 ident -> right = tmp ;
676685 //fixupInitializer(current, ident->right, basetype);
677686 if (ident -> right -> kind == AST_EXPRLIST ) {
0 commit comments