summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--opt.c6
-rwxr-xr-xtests.sh8
2 files changed, 11 insertions, 3 deletions
diff --git a/opt.c b/opt.c
index 8bc990e..820f421 100644
--- a/opt.c
+++ b/opt.c
@@ -803,6 +803,10 @@ static struct expr *optimize_expr_recursive(struct opt_state *state, struct expr
state->facts_when_true = state->facts;
state->facts_when_false = state->facts;
+ if (!expr->rhs && !expr->pure) {
+ facts_union(state->facts_when_impure, state->facts_when_impure, &state->facts);
+ }
+
if (expr->eval == eval_access) {
infer_access_facts(state, expr);
} else if (expr->eval == eval_acl) {
@@ -847,8 +851,6 @@ static struct expr *optimize_expr_recursive(struct opt_state *state, struct expr
expr = optimize_or_expr_recursive(state, expr);
} else if (expr->eval == eval_comma) {
expr = optimize_comma_expr_recursive(state, expr);
- } else if (!expr->pure) {
- facts_union(state->facts_when_impure, state->facts_when_impure, &state->facts);
}
if (!expr) {
diff --git a/tests.sh b/tests.sh
index df92a8e..c84907c 100755
--- a/tests.sh
+++ b/tests.sh
@@ -657,10 +657,11 @@ bfs_tests=(
test_L_unique_depth
test_xtype_multi
- test_xtype_reorder
# Optimizer tests
test_data_flow_hidden
+ test_xtype_reorder
+ test_xtype_depth
# PATH_MAX handling
test_deep_strict
@@ -1323,6 +1324,11 @@ function test_xtype_reorder() {
invoke_bfs loops -links 100 -xtype l
}
+function test_xtype_depth() {
+ # Make sure -xtype is considered side-effecting for facts_when_impure
+ ! invoke_bfs loops -xtype l -depth 100 2>/dev/null
+}
+
function test_iname() {
bfs_diff basic -iname '*F*'
}