1 // PR target/29487 2 // { dg-do link } 3 // { dg-options "-O2" } 4 5 /* This function is not defined. The compiler should optimize away 6 all calls to it. */ 7 extern void undefined () throw (); 8 9 extern void f1(); 10 f2()11inline void f2() { 12 f1(); 13 } 14 15 /* This function will be COMDAT if not inlined. */ f1()16inline void f1() {} 17 18 /* This function will be COMDAT. */ 19 template <typename T> f3()20void f3() { 21 if (false) 22 throw 3; 23 } 24 f4()25inline void f4() { 26 if (false) 27 throw 7; 28 } 29 main()30int main () { 31 try { 32 f1(); 33 f2(); 34 f3<int>(); 35 f4(); 36 } catch (...) { 37 /* The compiler should recognize that none of the functions above 38 can throw exceptions, and therefore remove this code as 39 unreachable. */ 40 undefined (); 41 } 42 } 43