From f5995bf40e7163aac9fa7a7738e83467f16cbe36 Mon Sep 17 00:00:00 2001 From: Benjamin Bannier Date: Tue, 16 May 2023 23:34:23 +0200 Subject: [PATCH] fixup! fixup! Functions with locals of structs with lifecycle hooks are not pure. --- tests/Baseline/hilti.optimization.dead_code/opt.hlt | 11 ++++++----- tests/hilti/optimization/dead_code.hlt | 9 +++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/tests/Baseline/hilti.optimization.dead_code/opt.hlt b/tests/Baseline/hilti.optimization.dead_code/opt.hlt index 9784133ee..adf5a7d5c 100644 --- a/tests/Baseline/hilti.optimization.dead_code/opt.hlt +++ b/tests/Baseline/hilti.optimization.dead_code/opt.hlt @@ -1,14 +1,15 @@ ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. module foo { -type X = struct { +type Y = struct { + hook void ~finally() {} }; global uint<64> num_calls = 0; -function X fn_pure3() &pure { - local X x; - return x; +function Y fn_pure4() { + local Y y; + return y; } function uint<64> fn_not_pure() { @@ -16,7 +17,7 @@ function uint<64> fn_not_pure() { return 0; } -fn_pure3(); +fn_pure4(); fn_not_pure(); } diff --git a/tests/hilti/optimization/dead_code.hlt b/tests/hilti/optimization/dead_code.hlt index 33f68894a..c83a4dd7c 100644 --- a/tests/hilti/optimization/dead_code.hlt +++ b/tests/hilti/optimization/dead_code.hlt @@ -15,6 +15,14 @@ function X fn_pure3() { return x; } +type Y = struct { + hook void ~finally() {} +}; +function Y fn_pure4() { + local Y y; + return y; +} + global uint<64> num_calls = 0; function uint<64> fn_not_pure() { num_calls += 1; @@ -27,6 +35,7 @@ default(); fn_pure1(); fn_pure2(); fn_pure3(); +fn_pure4(); fn_not_pure(); }