1 // Test for noexcept-specification
2 // { dg-do compile { target c++11 } }
4 #define SA(X) static_assert(X, #X)
7 void f() noexcept(false);
8 void f() noexcept(1 == 0);
13 void g() throw (int); // { dg-message "previous declaration" "" { target { ! c++17 } } }
14 // { dg-error "dynamic exception specification" "" { target c++17 } .-1 }
15 // { dg-warning "deprecated" "" { target { ! c++17 } } .-2 }
16 void g() noexcept(false); // { dg-error "different exception" "" { target { ! c++17 } } }
25 void g (T) noexcept(noexcept(T())); // { dg-message "previous declaration" }
27 void g (T) noexcept(noexcept(T(0))); // { dg-error "different exception" }
30 void f (T) noexcept(noexcept(T()) && noexcept(T()));
32 void f (T) noexcept(noexcept(T()) && noexcept(T()));
34 void f2(T a) noexcept (noexcept (f (a)));
38 SA(!noexcept(f(A())));
40 SA(!noexcept(f2(A())));
42 template <class... Ts>
43 void f3(Ts... ts) noexcept (noexcept (f(ts...)));
46 SA(!noexcept(f3(A())));
48 template <class T1, class T2>
49 void f (T1, T2) noexcept(noexcept(T1(), T2()));
53 SA(noexcept(f3(1,B())));
54 SA(!noexcept(f3(1,A())));
55 SA(!noexcept(f3(A(),1)));
56 SA(!noexcept(f3(A(),A())));