Debian Codegraph @

gcc/testsuite/g++.dg/eh/comdat1.C

raw
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
11 inline void f2() {
12 f1();
13 }
14
15 /* This function will be COMDAT if not inlined. */
16 inline void f1() {}
17
18 /* This function will be COMDAT. */
19 template <typename T>
20 void f3() {
21 if (false)
22 throw 3;
23 }
24
25 inline void f4() {
26 if (false)
27 throw 7;
28 }
29
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 }
42 }