diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-06-05 22:23:23 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-06-05 23:26:43 -0400 |
| commit | bd13e757e7e36994d2a1fd4595c617d14e22b7c6 (patch) | |
| tree | 956870c725e4cf9f9a8097204c2a93ac18a9f409 /src/ir.cpp | |
| parent | 0ccc18686921dce8e7f2feb95eed83b894ca8df4 (diff) | |
| download | zig-bd13e757e7e36994d2a1fd4595c617d14e22b7c6.tar.gz zig-bd13e757e7e36994d2a1fd4595c617d14e22b7c6.zip | |
disable deref syntax for unknown length pointers
See #770
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 5c44e7c0ff..a6686aae76 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -11132,7 +11132,13 @@ static TypeTableEntry *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp * static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp *bin_op_instruction) { IrInstruction *op1 = bin_op_instruction->op1->other; + if (type_is_invalid(op1->value.type)) + return ira->codegen->builtin_types.entry_invalid; + IrInstruction *op2 = bin_op_instruction->op2->other; + if (type_is_invalid(op2->value.type)) + return ira->codegen->builtin_types.entry_invalid; + IrBinOp op_id = bin_op_instruction->op_id; // look for pointer math @@ -12851,6 +12857,12 @@ static TypeTableEntry *ir_analyze_dereference(IrAnalyze *ira, IrInstructionUnOp if (type_is_invalid(ptr_type)) { return ira->codegen->builtin_types.entry_invalid; } else if (ptr_type->id == TypeTableEntryIdPointer) { + if (ptr_type->data.pointer.ptr_len == PtrLenUnknown) { + ir_add_error_node(ira, un_op_instruction->base.source_node, + buf_sprintf("index syntax required for unknown-length pointer type '%s'", + buf_ptr(&ptr_type->name))); + return ira->codegen->builtin_types.entry_invalid; + } child_type = ptr_type->data.pointer.child_type; } else { ir_add_error_node(ira, un_op_instruction->base.source_node, |
