[midend]修复多维数组维度信息的计算值(理论上计算结果一定是常量),TODO:修复类似问题
This commit is contained in:
@ -895,7 +895,7 @@ std::any SysYIRGenerator::visitFuncDef(SysYParser::FuncDefContext *ctx){
|
|||||||
currentParamDims.push_back(ConstantInteger::get(-1)); // 标记第一个维度为未知
|
currentParamDims.push_back(ConstantInteger::get(-1)); // 标记第一个维度为未知
|
||||||
for (const auto &exp : param->exp()) {
|
for (const auto &exp : param->exp()) {
|
||||||
// 访问表达式以获取维度大小,这些维度必须是常量
|
// 访问表达式以获取维度大小,这些维度必须是常量
|
||||||
Value* dimVal = std::any_cast<Value *>(visitExp(exp));
|
Value* dimVal = computeExp(exp);
|
||||||
// 确保维度是常量整数,否则 buildArrayType 会断言失败
|
// 确保维度是常量整数,否则 buildArrayType 会断言失败
|
||||||
assert(dynamic_cast<ConstantInteger*>(dimVal) && "Array dimension in parameter must be a constant integer!");
|
assert(dynamic_cast<ConstantInteger*>(dimVal) && "Array dimension in parameter must be a constant integer!");
|
||||||
currentParamDims.push_back(dimVal);
|
currentParamDims.push_back(dimVal);
|
||||||
|
|||||||
Reference in New Issue
Block a user