source: tests/except-finally-error.cfa @ d62806c

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since d62806c was d62806c, checked in by Andrew Beach <ajbeach@…>, 4 years ago

Start working on checks to make sure we do not jump out of a finally block.

  • Property mode set to 100644
File size: 835 bytes
Line 
1// All of these should be caught as long as the check remains in the same
2// pass. (Although not even all of the checks are in place yet.)
3
4void break_in_finally() {
5        while (true) {
6                try {} finally {
7                        break;
8                }
9        }
10}
11
12void continue_in_finally() {
13        while (true) {
14                try {} finally {
15                        continue;
16                }
17        }
18}
19
20void goto_in_finally() {
21        while (true) {
22                try {} finally {
23                        goto end_of_function;
24                }
25        }
26        end_of_function: {}
27}
28
29void labelled_break_in_finally() {
30        mainLoop: while (true) {
31                try {} finally {
32                        break mainLoop;
33                }
34        }
35}
36
37void labelled_continue_in_finally() {
38        mainLoop: while (true) {
39                try {} finally {
40                        continue mainLoop;
41                }
42        }
43}
44
45void void_return_in_finally() {
46        try {} finally {
47                return;
48        }
49}
50
51int value_return_in_finally() {
52        try {} finally {
53                return -7;
54        }
55
56}
57
58void main() {
59        // Should not compile.
60        return 1;
61}
Note: See TracBrowser for help on using the repository browser.