* decl.c (make_typename_type): s/parameters/arguments/.
[official-gcc.git] / gcc / testsuite / g++.dg / cpp0x / noexcept03.C
blob2d378677b7fdac6a249e6a02e47faeb9be8f0e10
1 // Runtime test for noexcept-specification.
2 // { dg-options "-Wnoexcept" }
3 // { dg-do run { target nonpic } }
4 // { dg-require-effective-target c++11 }
6 #include <exception>
7 #include <cstdlib>
9 void my_terminate ()
11   std::exit (0);
14 void my_unexpected ()
16   throw;
19 void g() { throw 1; }
20 void (*p)() = g;
21 void f () noexcept (false)
23   p();
26 template <class T>
27 void f(T) noexcept (noexcept (T())) // { dg-warning "false" }
29   p();
32 template <class T>
33 void f2(T a) noexcept (noexcept (f (a)))
35   f(a);
38 struct A { A() { } };           // { dg-warning "does not throw" }
40 int main()
42   // noexcept(false) allows throw.
43   try { f(); } catch (int) { }
44   // noexcept(noexcept(A())) == noexcept(false).
45   try { f(A()); } catch (int) { }
46   try { f2(A()); } catch (int) { }
48   std::set_terminate (my_terminate);
49   // noexcept(noexcept(int())) == noexcept(true).
50   try { f2(1); } catch (...) { }
51   return 1;