[midend]修复多维数组维度信息的计算值(理论上计算结果一定是常量),TODO:修复类似问题

This commit is contained in:
rain2133
2025-08-01 19:19:05 +08:00
parent aef10b48e8
commit e48cddab9f

View File

@ -895,7 +895,7 @@ std::any SysYIRGenerator::visitFuncDef(SysYParser::FuncDefContext *ctx){
currentParamDims.push_back(ConstantInteger::get(-1)); // 标记第一个维度为未知
for (const auto &exp : param->exp()) {
// 访问表达式以获取维度大小,这些维度必须是常量
Value* dimVal = std::any_cast<Value *>(visitExp(exp));
Value* dimVal = computeExp(exp);
// 确保维度是常量整数,否则 buildArrayType 会断言失败
assert(dynamic_cast<ConstantInteger*>(dimVal) && "Array dimension in parameter must be a constant integer!");
currentParamDims.push_back(dimVal);