File tree Expand file tree Collapse file tree 1 file changed +29
-1
lines changed
Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -1288,7 +1288,35 @@ TACOperand TACGenerator::generate_call(std::shared_ptr<CallExpr> expr)
12881288 std::vector<TACOperand> args;
12891289 args.reserve (expr->arguments .size ());
12901290 for (const auto &arg : expr->arguments ) {
1291- args.push_back (generate_expression (arg));
1291+ auto arg_operand = generate_expression (arg);
1292+
1293+ if (arg->type == ASTNodeType::IDENTIFIER_EXPR) {
1294+ auto arg_type_result = get_expression_type (arg);
1295+ if (arg_type_result.is_ok ()) {
1296+ TypePtr arg_type = strip_typedefs (arg_type_result.value ());
1297+ if (arg_type && arg_type->kind == TypeKind::ARRAY) {
1298+ auto array_type =
1299+ std::static_pointer_cast<ArrayType>(arg_type);
1300+ auto ptr_result =
1301+ type_factory.get_pointer (array_type->element_type );
1302+ if (ptr_result.is_ok ()) {
1303+ TypePtr ptr_type = ptr_result.value ();
1304+ auto addr_temp = new_temp (ptr_type);
1305+ auto addr_operand =
1306+ TACOperand::temporary (addr_temp, ptr_type);
1307+
1308+ emit (
1309+ std::make_shared<TACInstruction>(TACOpcode::ADDR_OF,
1310+ addr_operand,
1311+ arg_operand));
1312+
1313+ arg_operand = addr_operand;
1314+ }
1315+ }
1316+ }
1317+ }
1318+
1319+ args.push_back (arg_operand);
12921320 }
12931321
12941322 for (const auto &arg : args) {
You can’t perform that action at this time.
0 commit comments