1 // PERMUTE_ARGS: -fPIC 2 3 extern(C) int printf(const char*, ...); 4 5 class Abc : Throwable 6 { this()7 this() pure 8 { 9 super(""); 10 } 11 static int x; 12 int a,b,c; 13 test()14 synchronized void test() 15 { 16 printf("test 1\n"); 17 x |= 1; 18 foo(); 19 printf("test 2\n"); 20 x |= 2; 21 } 22 foo()23 shared void foo() 24 { 25 printf("foo 1\n"); 26 x |= 4; 27 throw this; 28 printf("foo 2\n"); 29 x |= 8; 30 } 31 } 32 33 struct RefCounted 34 { 35 void *p; ~thisRefCounted36 ~this() 37 { 38 p = null; 39 } 40 } 41 42 struct S 43 { 44 RefCounted _data; 45 get()46 int get() @property 47 { 48 throw new Exception(""); 49 } 50 } 51 b9438()52void b9438() 53 { 54 try 55 { 56 S s; 57 S().get; 58 } 59 catch (Exception e){ } 60 } 61 main()62int main() 63 { 64 printf("hello world\n"); 65 auto a = new shared(Abc)(); 66 printf("hello 2\n"); 67 Abc.x |= 0x10; 68 69 try 70 { 71 Abc.x |= 0x20; 72 a.test(); 73 Abc.x |= 0x40; 74 } 75 catch (shared(Abc) b) 76 { 77 Abc.x |= 0x80; 78 printf("Caught %p, x = x%x\n", b, Abc.x); 79 assert(a is b); 80 assert(Abc.x == 0xB5); 81 } 82 printf("Success!\n"); 83 b9438(); 84 return 0; 85 } 86