Skip to content

[Phase4:bug in ast.cpp] No need to Add instruction goto next in function CAstStatAssign::ToTac #11

@alapha23

Description

@alapha23

There seems of no use to add a goto at the end of CAstStatAssign::ToTac()

The redundant line is marked in the code block.

In control flows, there will be a goto in the intermediate code, which is actually a infinite loop. Please refer to test/tac/test3.mod to check the result.

CTacAddr* CAstStatAssign::ToTac(CCodeBlock *cb, CTacLabel *next)
{
  // CTacAddr *dst = GetLHS()->ToTac(cb);
  CTacAddr *src = GetRHS()->ToTac(cb); // gets the TAC of RHS
  CTacAddr *dst = GetLHS()->ToTac(cb); // gets the TAC of LHS

  cb->AddInstr(new CTacInstr(opAssign, dst, src));

  cb->AddInstr(new CTacInstr(opGoto, next));  // this line is redundant

  return NULL;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions