diff options
author | Heejin Ahn <aheejin@gmail.com> | 2021-11-08 22:44:29 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-08 22:44:29 -0800 |
commit | 1ad4e23342ef83b9210ce81bbf119047e08b6f3b (patch) | |
tree | 652dd07126bb7251cb7d3811fefb968ae684f173 /test/exception-handling.wast | |
parent | 31a5bf7ad7dbe30ec47766271ba13276117f98a0 (diff) | |
download | binaryen-1ad4e23342ef83b9210ce81bbf119047e08b6f3b.tar.gz binaryen-1ad4e23342ef83b9210ce81bbf119047e08b6f3b.tar.bz2 binaryen-1ad4e23342ef83b9210ce81bbf119047e08b6f3b.zip |
[EH] Improve catch validation (#4315)
This improves validation of `catch` bodies mostly by checking the
validity of `pop`s.
For every `catch` body:
- Checks if its tag exists
- If the tag's type is none:
- Ensures there shouldn't be any `pop`s
- If the tag's type is not none:
- Checks if there's a single `pop` within the catch body
- Checks if the tag type matches the `pop`'s type
- Checks if the `pop`'s location is valid
For every `catch_all` body:
- Ensures there shuldn't be any `pop`s
This uncovers several bugs related to `pop`s in existing tests, which
this PR also fixes.
Diffstat (limited to 'test/exception-handling.wast')
-rw-r--r-- | test/exception-handling.wast | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/exception-handling.wast b/test/exception-handling.wast index c608e860a..cd436296b 100644 --- a/test/exception-handling.wast +++ b/test/exception-handling.wast @@ -2,6 +2,7 @@ (tag $e-i32 (param i32)) (tag $e-i64 (param i64)) (tag $e-i32-i64 (param i32 i64)) + (tag $e-anyref (param anyref)) (tag $e-empty) (func $foo) @@ -311,4 +312,29 @@ ) ) ) + + (func $pop_test + (try + (do) + (catch $e-i32 + (throw $e-i32 + (if (result i32) + ;; pop is within an if condition, so this is OK. + (pop i32) + (i32.const 0) + (i32.const 3) + ) + ) + ) + ) + + (try + (do) + (catch $e-anyref + (drop + (pop funcref) ;; pop can be subtype + ) + ) + ) + ) ) |