[midend]修复return指令exp为空的判断条件错误

This commit is contained in:
rain2133
2025-07-29 12:16:46 +08:00
parent 76d7b14b2e
commit 4a329eeaf2

View File

@ -712,7 +712,7 @@ std::any SysYIRGenerator::visitReturnStmt(SysYParser::ReturnStmtContext *ctx) {
}
Type* funcType = builder.getBasicBlock()->getParent()->getReturnType();
if (funcType!= returnValue->getType() && returnValue != nullptr) {
if (returnValue != nullptr && funcType!= returnValue->getType()) {
ConstantValue * constValue = dynamic_cast<ConstantValue *>(returnValue);
if (constValue != nullptr) {
if (funcType == Type::getFloatType()) {