aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/eh/comdat1.C
blob: 4a118051145196985991a0e24fe944d727e4247b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// PR target/29487
// { dg-do link }
// { dg-options "-O2" }

/* This function is not defined.  The compiler should optimize away
   all calls to it.  */
extern void undefined () throw ();

extern void f1();

inline void f2() {
  f1();
}

/* This function will be COMDAT if not inlined.  */
inline void f1() {}

/* This function will be COMDAT.  */
template <typename T>
void f3() {
  if (false)
    throw 3;
}

inline void f4() {
  if (false)
    throw 7;
}

int main () {
  try {
    f1();
    f2();
    f3<int>();
    f4();
  } catch (...) {
    /* The compiler should recognize that none of the functions above
       can throw exceptions, and therefore remove this code as
       unreachable.  */
    undefined ();
  }
}