1 // RUN: %clang_cc1 -std=c++11 %s -verify -fcxx-exceptions
3 // We permit overriding an implicit exception specification with an explicit one
4 // as an extension, for compatibility with existing code.
7 void a(); // expected-note {{here}}
8 ~S(); // expected-note {{here}}
9 void operator delete(void*); // expected-note {{here}}
12 void S::a() noexcept
{} // expected-error {{does not match previous}}
13 S::~S() noexcept
{} // expected-warning {{function previously declared with an implicit exception specification redeclared with an explicit exception specification}}
14 void S::operator delete(void*) noexcept
{} // expected-warning {{function previously declared with an implicit exception specification redeclared with an explicit exception specification}}
17 void a() noexcept
; // expected-note {{here}}
18 ~T() noexcept
; // expected-note {{here}}
19 void operator delete(void*) noexcept
; // expected-note {{here}}
22 void T::a() {} // expected-error {{missing exception specification 'noexcept'}}
23 T::~T() {} // expected-warning {{function previously declared with an explicit exception specification redeclared with an implicit exception specification}}
24 void T::operator delete(void*) {} // expected-warning {{function previously declared with an explicit exception specification redeclared with an implicit exception specification}}
27 // The extension does not extend to function templates.
29 template<typename T
> struct U
{
31 ~U(); // expected-note {{here}}
32 void operator delete(void*); // expected-note {{here}}
35 template<typename T
> U
<T
>::~U() noexcept(true) {} // expected-error {{exception specification in declaration does not match previous declaration}}
36 template<typename T
> void U
<T
>::operator delete(void*) noexcept(false) {} // expected-error {{exception specification in declaration does not match previous declaration}}
39 // Make sure this restriction interacts properly with __attribute__((noreturn))
40 void __attribute__ ((__noreturn__
)) PR17110(int status
) throw();
41 void PR17110(int status
) throw();