aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-04-04 21:36:24 -0400
committerAndrew Kelley <superjoe30@gmail.com>2017-04-04 21:36:24 -0400
commita461ae6c1fd1f8a75126327f104c7c077d35f0a5 (patch)
tree8f4346d387bf930e5e770985594aec4ab82074e0 /src/ir.cpp
parente30f713640be6590a81f23abe9571869469a5d35 (diff)
downloadzig-a461ae6c1fd1f8a75126327f104c7c077d35f0a5.tar.gz
zig-a461ae6c1fd1f8a75126327f104c7c077d35f0a5.zip
fix crash when referencing invalid member of builtin enum
closes #304
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 6f5f5fbbd2..1fb839ea9d 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -9396,10 +9396,12 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
}
}
ScopeDecls *container_scope = get_container_scope(child_type);
- auto entry = container_scope->decl_table.maybe_get(field_name);
- Tld *tld = entry ? entry->value : nullptr;
- if (tld) {
- return ir_analyze_decl_ref(ira, &field_ptr_instruction->base, tld);
+ if (container_scope != nullptr) {
+ auto entry = container_scope->decl_table.maybe_get(field_name);
+ Tld *tld = entry ? entry->value : nullptr;
+ if (tld) {
+ return ir_analyze_decl_ref(ira, &field_ptr_instruction->base, tld);
+ }
}
ir_add_error(ira, &field_ptr_instruction->base,
buf_sprintf("container '%s' has no member called '%s'",