diff --git a/src/SysYIRGenerator.cpp b/src/SysYIRGenerator.cpp index 1fb7305..2fa2be8 100644 --- a/src/SysYIRGenerator.cpp +++ b/src/SysYIRGenerator.cpp @@ -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(returnValue); if (constValue != nullptr) { if (funcType == Type::getFloatType()) {