diff options
| author | gingerBill <bill@gingerbill.org> | 2020-06-18 17:50:54 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2020-06-18 17:50:54 +0100 |
| commit | 2a684830f984f03bc2ff2443923c40a592878508 (patch) | |
| tree | 788abd80297358bb970338baf509666f13461e65 /src/check_stmt.cpp | |
| parent | c4ba3f1c8397eb3b88434089bf3afdd4c86c4fc6 (diff) | |
Fix using pointers bug with addressing struct fields
Diffstat (limited to 'src/check_stmt.cpp')
| -rw-r--r-- | src/check_stmt.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp index 9c2a32b75..f45fb83fe 100644 --- a/src/check_stmt.cpp +++ b/src/check_stmt.cpp @@ -562,6 +562,7 @@ bool check_using_stmt_entity(CheckerContext *ctx, AstUsingStmt *us, Ast *expr, b } case Entity_Variable: { + bool is_ptr = is_type_pointer(e->type); Type *t = base_type(type_deref(e->type)); if (t->kind == Type_Struct) { // TODO(bill): Make it work for unions too @@ -570,7 +571,7 @@ bool check_using_stmt_entity(CheckerContext *ctx, AstUsingStmt *us, Ast *expr, b Entity *f = found->elements.entries[i].value; if (f->kind == Entity_Variable) { Entity *uvar = alloc_entity_using_variable(e, f->token, f->type, expr); - if (e->flags & EntityFlag_Value) uvar->flags |= EntityFlag_Value; + if (!is_ptr && e->flags & EntityFlag_Value) uvar->flags |= EntityFlag_Value; if (e->flags & EntityFlag_Param) uvar->flags |= EntityFlag_Param; Entity *prev = scope_insert(ctx->scope, uvar); if (prev != nullptr) { |