1 2 3// TEST-OPTIONS: -x c exception_missing_eh2.c -arch i386 4// TEST-OPTIONS: -x c exception_missing_eh2.c -arch i386 -Wl,-no_compact_unwind 5// TEST-OPTIONS: -x c exception_missing_eh2.c -arch ppc 6// TEST-OPTIONS: exception_missing_eh2_x86_64.s -arch x86_64 7// TEST-OPTIONS: exception_missing_eh2_x86_64.s -arch x86_64 -Wl,-no_compact_unwind 8 9 10#include <stdlib.h> 11 12#include <exception> 13 14extern "C" { 15 extern int bar(); 16 extern int foo(); 17} 18 19 20int foo() { throw 10; } 21 22static void term() 23{ 24 // terminate called, as we want 25 exit(0); 26} 27 28 29int main() 30{ 31 std::set_terminate(term); 32 33 int state = 1; 34 try { 35 state = 2; 36 // bar() calls foo() which throws 37 // but, bar is missing eh info, so terminate() is called 38 bar(); 39 state = 3; 40 } 41 catch (int x) { 42 if ( state != 2 ) 43 return 1; 44 if ( x != 10 ) 45 return 1; 46 state = 4; 47 } 48 49 // should not get here 50 exit(1); 51} 52 53