aboutsummaryrefslogtreecommitdiff
path: root/src/analyze.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-04-12 17:33:46 -0700
committerAndrew Kelley <superjoe30@gmail.com>2016-04-12 17:33:46 -0700
commit3c27cb25279049cfdcde99d49045f5b8ec8981ba (patch)
tree7a9b9ba96c7f18096a669b3daa450fcc30ce6175 /src/analyze.cpp
parent69109bc270c3167a3534dd32fc4f4def855e0be9 (diff)
downloadzig-3c27cb25279049cfdcde99d49045f5b8ec8981ba.tar.gz
zig-3c27cb25279049cfdcde99d49045f5b8ec8981ba.zip
more eval tests and fix eval call analyze code
Diffstat (limited to 'src/analyze.cpp')
-rw-r--r--src/analyze.cpp17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp
index 0cd234e3b8..f24d538ad8 100644
--- a/src/analyze.cpp
+++ b/src/analyze.cpp
@@ -4504,28 +4504,23 @@ static TypeTableEntry *analyze_fn_call_ptr(CodeGen *g, ImportTableEntry *import,
}
FnTableEntry *fn_table_entry = node->data.fn_call_expr.fn_entry;
- if (ok_invocation && fn_table_entry && fn_table_entry->is_pure && all_args_const_expr) {
+ if (ok_invocation && fn_table_entry && fn_table_entry->is_pure) {
if (fn_table_entry->anal_state == FnAnalStateReady) {
analyze_fn_body(g, fn_table_entry);
- } else if (fn_table_entry->anal_state == FnAnalStateProbing) {
- mark_impure_fn(context);
}
- if (fn_table_entry->is_pure) {
- if (fn_table_entry->anal_state == FnAnalStateComplete) {
+ if (all_args_const_expr) {
+ if (fn_table_entry->is_pure && fn_table_entry->anal_state == FnAnalStateComplete) {
ConstExprValue *result_val = &get_resolved_expr(node)->const_val;
if (eval_fn(g, node, fn_table_entry, result_val, 1000, struct_node)) {
// function evaluation generated an error
return g->builtin_types.entry_invalid;
}
return return_type;
- } else if (fn_table_entry->anal_state == FnAnalStateSkipped) {
- return g->builtin_types.entry_invalid;
}
- } else {
- // calling an impure fn is impure
- mark_impure_fn(context);
}
- } else {
+ }
+ if (!ok_invocation || !fn_table_entry || !fn_table_entry->is_pure) {
+ // calling an impure fn is impure
mark_impure_fn(context);
}