// 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
intputs(constchar*);template<typename T>intprintf(constchar*,T);constchar*strdup(constchar*);voidfree(constvoid*);#defineEXCEPTION_EXECUTE_HANDLER1classException{public:Exception(constchar*s="Unknown"){what =strdup(s);}Exception(const Exception&e){what =strdup(e.what);}~Exception(){free(what);}constchar*msg()const{return what;}private:constchar* what;};intmain(){float e, f, g;try{try{
f =1.0;
g =0.0;try{puts("Another exception:");
e = f / g;}__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());}}
__finally
{puts("C++ allows __finally too!");}return e;}namespacePR17584{template<typename>voidExcept(){
__try {}__except(true){}}template<typename>voidFinally(){
__try {} __finally {}}templatevoidExcept<void>();templatevoidFinally<void>();}voidtest___leave(){// 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.
try{
__leave;// expected-error{{'__leave' statement not in __try block}}
} __finally {}}