Skip to content

Commit 8f7f0f6

Browse files
committed
fix(parser): handle address_of and pointer_deref
Signed-off-by: vibhatsu <maulikbarot2915@gmail.com>
1 parent 4571d8b commit 8f7f0f6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/parser/parser.y

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,6 +1442,24 @@ static void check_array_bounds(const TypePtr &array_type,
14421442
// Validate builtin type
14431443
if (type_validator(operand_type)) {
14441444
TypePtr result_type = operand_type;
1445+
1446+
if (op_enum == Operator::ADDRESS_OF) {
1447+
QualifiedType ptr_type = apply_pointer_levels_or_error(
1448+
QualifiedType(operand_type, Qualifier::NONE),
1449+
1,
1450+
op_name,
1451+
loc.begin.line,
1452+
loc.begin.column
1453+
);
1454+
result_type = ptr_type.type;
1455+
}
1456+
else if (op_enum == Operator::POINTER_DEREF) {
1457+
result_type = dereference_pointer(operand_type, loc, op_name);
1458+
if (!result_type) {
1459+
return nullptr;
1460+
}
1461+
}
1462+
14451463
auto unary_expr = std::make_shared<UnaryExpr>(op_enum, operand, result_type);
14461464

14471465
// Set lvalue status based on operator type

0 commit comments

Comments
 (0)