Changeset 553f032f for tests/exceptions


Ignore:
Timestamp:
Sep 8, 2023, 5:15:41 PM (16 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
5cfb8b1
Parents:
2fa0237
Message:

Insert additional checks so that impossible, or just unimplemented, local control flow raises an error in CFA.

Location:
tests/exceptions
Files:
1 added
1 deleted
1 moved

Legend:

Unmodified
Added
Removed
  • tests/exceptions/try-ctrl-flow.cfa

    r2fa0237 r553f032f  
    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.)
     1// Check all the local control flow structures that are "sealed" by some the
     2// try statement clauses; where structured programming is stricter.
    33
    44void break_in_finally() {
     
    151151}
    152152
     153// Now just use return to test the other try control flow interactions.
     154
     155exception nil_exception {};
     156
     157void return_in_try_with_catch() {
     158        try {
     159                return;
     160        } catch (nil_exception *) {
     161                ;
     162        }
     163}
     164
     165// Allowed.
     166void return_in_try_with_catchReturn() {
     167        try {
     168                return;
     169        } catchResume (nil_exception *) {
     170                ;
     171        }
     172}
     173
     174// Allowed.
     175void return_in_try_with_finally() {
     176        try {
     177                return;
     178        } finally {
     179                ;
     180        }
     181}
     182
     183void return_in_catch() {
     184        try {
     185                ;
     186        } catch (nil_exception *) {
     187                return;
     188        }
     189}
     190
     191void return_in_catchResume() {
     192        try {
     193                ;
     194        } catchResume (nil_exception *) {
     195                return;
     196        }
     197}
     198
    153199void main() {
    154200        // Should not compile.
Note: See TracChangeset for help on using the changeset viewer.