1 // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 -fms-extensions -Wno-delete-incomplete %s
2 // expected-no-diagnostics
4 #define P(e) static_assert(noexcept(e), "expected nothrow")
5 #define N(e) static_assert(!noexcept(e), "expected throw")
6 #define B(b, e) static_assert(b == noexcept(e), "expectation failed")
14 P(static_cast<int>(0));
20 void allspec() throw(...);
21 void intspec() throw(int);
22 void emptyspec() throw();
23 void nothrowattr() __attribute__((nothrow));
24 void noexcept_true() noexcept;
25 void noexcept_false() noexcept(false);
38 void (*pallspec)() throw(...);
39 void (*pintspec)() throw(int);
40 void (*pemptyspec)() throw();
42 typedef void (*funcptr)();
43 funcptr returnsptr() throw();
59 void allspec() throw(...);
60 void intspec() throw(int);
61 void emptyspec() throw();
72 void (S1::*mpnospec)();
73 void (S1::*mpallspec)() throw(...);
74 void (S1::*mpintspec)() throw(int);
75 void (S1::*mpemptyspec)() throw();
82 P((s.*mpemptyspec)());
89 void operator -() throw();
91 void operator -(int) throw();
93 operator float() throw();
96 void *operator new(__typeof__(sizeof(int)) sz, int) throw();
98 struct IncompleteStruct;
104 void operator delete(void*) throw(int);
113 P(delete (IncompleteStruct*)0);
123 N(static_cast<int>(s));
124 P(static_cast<float>(s));
130 virtual ~V() throw();
137 P(dynamic_cast<V&>(*pd));
138 P(dynamic_cast<V*>(pd));
139 N(dynamic_cast<D&>(*pv));
140 P(dynamic_cast<D*>(pv));
155 P(sizeof(typeid(*(V*)0)));
156 P(typeid(typeid(*(V*)0)));
160 struct G2 { int i; };
169 template <class T> void f(T&&) noexcept;
170 template <typename T, bool b>
172 B(b, typeid(*(T*)0));
174 B(b, static_cast<T>(S2(0, 0)));
181 virtual ~S3() throw();
186 template <class T> T&& f2() noexcept;
187 template <typename T>
189 P(dynamic_cast<S3&>(f2<T&>()));
191 void operator +(const S1&, float) throw();
192 void operator +(const S1&, const S3&);