1 // RUN: %clang_cc1 -std=c++11 %s -verify -fcxx-exceptions 2 3 // We permit overriding an implicit exception specification with an explicit one 4 // as an extension, for compatibility with existing code. 5 6 struct S { 7 void a(); // expected-note {{here}} 8 ~S(); // expected-note {{here}} 9 void operator delete(void*); // expected-note {{here}} 10 }; 11 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}} 15 16 struct T { 17 void a() noexcept; // expected-note {{here}} 18 ~T() noexcept; // expected-note {{here}} 19 void operator delete(void*) noexcept; // expected-note {{here}} 20 }; 21 22 void T::a() {} // expected-warning {{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}} 25 26 27 // The extension does not extend to function templates. 28 29 template<typename T> struct U { 30 T t; 31 ~U(); // expected-note {{here}} 32 void operator delete(void*); // expected-note {{here}} 33 }; 34 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}} 37 38 39 // Make sure this restriction interacts properly with __attribute__((noreturn)) 40 void __attribute__ ((__noreturn__)) PR17110(int status) throw(); 41 void PR17110(int status) throw(); 42