| // RUN: %clang_cc1 -triple x86_64-windows -fsyntax-only -verify -fborland-extensions -fcxx-exceptions %s |
| // This test is from http://docwiki.embarcadero.com/RADStudio/en/Try |
| int printf(const char *, T); |
| const char * strdup(const char *); |
| #define EXCEPTION_EXECUTE_HANDLER 1 |
| Exception(const char* s = "Unknown"){what = strdup(s); } |
| Exception(const Exception& e ){what = strdup(e.what); } |
| ~Exception() {free(what); } |
| const char* msg() const {return what; } |
| puts("Another exception:"); |
| __except(EXCEPTION_EXECUTE_HANDLER) |
| puts("Caught a C-based exception."); |
| throw(Exception("Hardware error: Divide by 0")); |
| catch(const Exception& e) |
| printf("Caught C++ Exception: %s :\n", e.msg()); |
| puts("C++ allows __finally too!"); |
| template void Except<void>(); |
| template void Finally<void>(); |
| // Most tests are in __try.c. |
| // Clang accepts try with __finally. MSVC doesn't. (Maybe a Borland thing?) |
| // __leave in mixed blocks isn't supported. |
| __leave; // expected-error{{'__leave' statement not in __try block}} |