diff --git a/src/context/mipsContext.cpp b/src/context/mipsContext.cpp index d8f55a9..11c323e 100644 --- a/src/context/mipsContext.cpp +++ b/src/context/mipsContext.cpp @@ -311,7 +311,10 @@ void MIPSContext::postProcessInstrs() { if (!Utils::vectorContains(_instrs[j].extraData, std::string("#raw"))) { - deallocSize += std::stoi(_instrs[j].input2); + if (!Utils::vectorContains(_instrs[j].extraData, std::string("#pop"))) + { + deallocSize += std::stoi(_instrs[j].input2); + } } } @@ -333,7 +336,10 @@ void MIPSContext::postProcessInstrs() { if (!Utils::vectorContains(_instrs[j].extraData, std::string("#raw"))) { - allocSize -= std::stoi(_instrs[j].input2); + if (!Utils::vectorContains(_instrs[j].extraData, std::string("#pop"))) + { + allocSize -= std::stoi(_instrs[j].input2); + } } } diff --git a/test/compiler/tests/loops/while_break_return.c b/test/compiler/tests/loops/while_break_return.c new file mode 100644 index 0000000..a723466 --- /dev/null +++ b/test/compiler/tests/loops/while_break_return.c @@ -0,0 +1,11 @@ +int while_break_return() +{ + int x, y, z; + while (x > 0) + { + break; + return 10; + } + + return 1; +} \ No newline at end of file diff --git a/test/compiler/tests/loops/while_break_return_driver.c b/test/compiler/tests/loops/while_break_return_driver.c new file mode 100644 index 0000000..03ff1ba --- /dev/null +++ b/test/compiler/tests/loops/while_break_return_driver.c @@ -0,0 +1,6 @@ +int while_break_return(); + +int main() +{ + return !(while_break_return() == 1); +} \ No newline at end of file diff --git a/test/parser/testProgram.c b/test/parser/testProgram.c index 74cdb44..9764bb3 100644 --- a/test/parser/testProgram.c +++ b/test/parser/testProgram.c @@ -1,26 +1,11 @@ -int switch_complex() +int main() { - int a = 3; - int b = 0; - switch (a) + int x, y, z; + while (x > 0) { - b = 4; - case 69: - { - return 69; - } - case 3: - - b += 5; - a = b + 6; - - case 5: - a += 45; - a++; break; - default: - return 2; + return 10; } - return a; -} + return 1; +} \ No newline at end of file