summaryrefslogtreecommitdiff
path: root/cgen.c
diff options
context:
space:
mode:
Diffstat (limited to 'cgen.c')
-rw-r--r--cgen.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/cgen.c b/cgen.c
index 78a2b5f..be35274 100644
--- a/cgen.c
+++ b/cgen.c
@@ -852,14 +852,15 @@ static bool cgen_expr(CGenerator *g, Expression *e) {
cgen_write(g, ")");
handled = true;
break;
- case BINARY_DOT:
+ case BINARY_DOT: {
cgen_write(g, "(");
cgen_expr(g, e->binary.lhs);
- cgen_write(g, ".");
+ bool is_ptr = type_inner(&e->binary.lhs->type)->kind == TYPE_PTR;
+ cgen_write(g, is_ptr ? "->" : ".");
cgen_ident(g, e->binary.field->name);
cgen_write(g, ")");
handled = true;
- break;
+ } break;
}
if (handled) break;
cgen_write(g, "(");