aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-02-23 16:52:13 -0500
committerAndrew Kelley <superjoe30@gmail.com>2017-02-23 16:52:13 -0500
commit3075d8aee728d10b1b8428ead070ba47856e78c3 (patch)
treeaa1fa35d29fd3c9fc87a11d944d9606314b53839 /src/ir.cpp
parentfe3063e58cf81287a26219903f2720439dfeb7e6 (diff)
downloadzig-3075d8aee728d10b1b8428ead070ba47856e78c3.tar.gz
zig-3075d8aee728d10b1b8428ead070ba47856e78c3.zip
fix use decls not always working
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp20
1 files changed, 4 insertions, 16 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index f9dd345ddf..28ae1bd1ad 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -3180,7 +3180,7 @@ static VariableTableEntry *create_local_var(CodeGen *codegen, AstNode *node, Sco
buf_sprintf("variable shadows type '%s'", buf_ptr(&type->name)));
variable_entry->value.type = codegen->builtin_types.entry_invalid;
} else {
- Tld *tld = find_decl(parent_scope, name);
+ Tld *tld = find_decl(codegen, parent_scope, name);
if (tld && tld->id != TldIdVar) {
ErrorMsg *msg = add_node_error(codegen, node,
buf_sprintf("redefinition of '%s'", buf_ptr(name)));
@@ -3676,7 +3676,7 @@ static IrInstruction *ir_gen_symbol(IrBuilder *irb, Scope *scope, AstNode *node,
return ir_build_load_ptr(irb, scope, node, var_ptr);
}
- Tld *tld = find_decl(scope, variable_name);
+ Tld *tld = find_decl(irb->codegen, scope, variable_name);
if (tld)
return ir_gen_decl_ref(irb, node, tld, lval, scope);
@@ -4210,7 +4210,7 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo
return irb->codegen->invalid_instruction;
}
Buf *variable_name = arg0_node->data.symbol_expr.symbol;
- Tld *tld = find_decl(scope, variable_name);
+ Tld *tld = find_decl(irb->codegen, scope, variable_name);
if (!tld) {
add_node_error(irb->codegen, node, buf_sprintf("use of undeclared identifier '%s'",
buf_ptr(variable_name)));
@@ -9333,19 +9333,7 @@ static TypeTableEntry *ir_analyze_instruction_field_ptr(IrAnalyze *ira, IrInstru
ImportTableEntry *namespace_import = namespace_val->data.x_import;
- Tld *tld = find_decl(&namespace_import->decls_scope->base, field_name);
- if (!tld) {
- // we must now resolve all the use decls
- // TODO move this check to find_decl?
- for (size_t i = 0; i < namespace_import->use_decls.length; i += 1) {
- AstNode *use_decl_node = namespace_import->use_decls.at(i);
- if (use_decl_node->data.use.resolution == TldResolutionUnresolved) {
- preview_use_decl(ira->codegen, use_decl_node);
- }
- resolve_use_decl(ira->codegen, use_decl_node);
- }
- tld = find_decl(&namespace_import->decls_scope->base, field_name);
- }
+ Tld *tld = find_decl(ira->codegen, &namespace_import->decls_scope->base, field_name);
if (tld) {
if (tld->visib_mod == VisibModPrivate &&
tld->import != source_node->owner)