* decl.c (make_typename_type): s/parameters/arguments/.
[official-gcc.git] / gcc / testsuite / g++.dg / cpp0x / noexcept01.C
blob9f425354bff4f69da1ffa64627d9a1b593a52ffd
1 // Test for noexcept-expression
2 // { dg-do compile { target c++11 } }
3 // { dg-options "-O2" }
5 #include <typeinfo>
7 #define SA(X) static_assert(X, #X)
9 void f();
10 void g() throw();
11 SA(noexcept(g()));
12 SA(!noexcept(f()));
13 SA(!noexcept(throw 1));
14 SA(noexcept(42));
16 struct A
18   virtual ~A();
21 struct B: public A
23   virtual ~B();
26 A* ap;
28 struct C { };
29 C* cp;
31 SA (noexcept (dynamic_cast<B*>(ap)));
32 SA (!noexcept (dynamic_cast<B&>(*ap)));
33 SA (!noexcept (typeid (*ap)));
34 SA (noexcept (typeid (*cp)));
36 SA (!noexcept (true ? 1 : throw 1));
37 SA (!noexcept (true || true ? 1 : throw 1));
39 SA (noexcept (C()));
41 struct D
43   D() throw();
46 SA (noexcept (D()));
48 struct E
50   E() throw();
51   ~E();
54 SA (noexcept (E()));
56 struct F
58   virtual void f();
61 SA (noexcept (F()));
63 struct G
65   G() = default;
66   ~G() = default;
69 SA (noexcept (G()));
71 template <class T, bool b>
72 void tf()
74   SA (noexcept (T()) == b);
77 template void tf<int,true>();
78 template void tf<E, true>();
80 // Make sure that noexcept uses the declared exception-specification, not
81 // any knowledge we might have about whether or not the function really
82 // throws.
83 void h() { }
84 SA(!noexcept(h()));