2018-11-07 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / g++.dg / eh / comdat1.C
blob4a118051145196985991a0e24fe944d727e4247b
1 // PR target/29487
2 // { dg-do link }
3 // { dg-options "-O2" }
5 /* This function is not defined.  The compiler should optimize away
6    all calls to it.  */
7 extern void undefined () throw ();
9 extern void f1();
11 inline void f2() {
12   f1();
15 /* This function will be COMDAT if not inlined.  */
16 inline void f1() {}
18 /* This function will be COMDAT.  */
19 template <typename T>
20 void f3() {
21   if (false)
22     throw 3;
25 inline void f4() {
26   if (false)
27     throw 7;
30 int 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   }