Merged revisions 208012,208018-208019,208021,208023-208030,208033,208037,208040-20804...
[official-gcc.git] / main / gcc / testsuite / g++.dg / cpp0x / noexcept02.C
blob5d5867af61aba1268dc922430be81d420ee40839
1 // Test for noexcept-specification
2 // { dg-do compile { target c++11 } }
4 #define SA(X) static_assert(X, #X)
6 void f();
7 void f() noexcept(false);
8 void f() noexcept(1 == 0);
9 void f();
11 SA(!noexcept(f()));
13 void g() throw (int);           // { dg-error "previous declaration" }
14 void g() noexcept(false);       // { dg-error "different exception" }
15 void g();
17 void h() throw();
18 void h() noexcept;
19 void h() throw();
20 void h() noexcept;
22 template <class T>
23 void g (T) noexcept(noexcept(T())); // { dg-error "previous declaration" }
24 template <class T>
25 void g (T) noexcept(noexcept(T(0))); // { dg-error "different exception" }
27 template <class T>
28 void f (T) noexcept(noexcept(T()) && noexcept(T()));
29 template <class T>
30 void f (T) noexcept(noexcept(T()) && noexcept(T()));
31 template <class T>
32 void f2(T a) noexcept (noexcept (f (a)));
34 struct A { A(); };
35 SA(noexcept(f(1)));
36 SA(!noexcept(f(A())));
37 SA(noexcept(f2(1)));
38 SA(!noexcept(f2(A())));
40 template <class... Ts>
41 void f3(Ts... ts) noexcept (noexcept (f(ts...)));
43 SA(noexcept(f3(1)));
44 SA(!noexcept(f3(A())));
46 template <class T1, class T2>
47 void f (T1, T2) noexcept(noexcept(T1(), T2()));
49 struct B { };
51 SA(noexcept(f3(1,B())));
52 SA(!noexcept(f3(1,A())));
53 SA(!noexcept(f3(A(),1)));
54 SA(!noexcept(f3(A(),A())));