diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-08-30 00:17:11 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-08-30 00:17:11 -0400 |
| commit | c2357830b4350a4685f867566afd79eaf2cb3c66 (patch) | |
| tree | 87e589aa52859f735e951f536c9f3525b11ea057 /src/ir.cpp | |
| parent | b35dad88b474bf346131696f5cb0e01a5b1c45c1 (diff) | |
| download | zig-c2357830b4350a4685f867566afd79eaf2cb3c66.tar.gz zig-c2357830b4350a4685f867566afd79eaf2cb3c66.zip | |
add "child" field to pointer type
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 243a8a2389..0c85437c2b 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -11416,6 +11416,20 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru buf_ptr(&child_type->name), buf_ptr(field_name))); return ira->codegen->builtin_types.entry_invalid; } + } else if (child_type->id == TypeTableEntryIdPointer) { + if (buf_eql_str(field_name, "child")) { + bool ptr_is_const = true; + bool ptr_is_volatile = false; + return ir_analyze_const_ptr(ira, &field_ptr_instruction->base, + create_const_type(ira->codegen, child_type->data.pointer.child_type), + ira->codegen->builtin_types.entry_type, + ConstPtrMutComptimeConst, ptr_is_const, ptr_is_volatile); + } else { + ir_add_error(ira, &field_ptr_instruction->base, + buf_sprintf("type '%s' has no member called '%s'", + buf_ptr(&child_type->name), buf_ptr(field_name))); + return ira->codegen->builtin_types.entry_invalid; + } } else { ir_add_error(ira, &field_ptr_instruction->base, buf_sprintf("type '%s' does not support field access", buf_ptr(&child_type->name))); |
