| 1 |
// RUN: %clang_cc1 -std=c++11 %s -fsyntax-only -verify -fms-compatibility -fexceptions -fcxx-exceptions |
| 2 |
// RUN: %clang_cc1 -std=c++17 %s -fsyntax-only -verify -fms-compatibility -fexceptions -fcxx-exceptions |
| 3 |
|
| 4 |
// FIXME: Should -fms-compatibility soften these errors into warnings to match |
| 5 |
// MSVC? In practice, MSVC never implemented dynamic exception specifiers, so |
| 6 |
// there isn't much Windows code in the wild that uses them. |
| 7 |
#if __cplusplus >= 201703L |
| 8 |
// expected-error@+3 {{ISO C++17 does not allow dynamic exception specifications}} |
| 9 |
// expected-note@+2 {{use 'noexcept(false)' instead}} |
| 10 |
#endif |
| 11 |
void f() throw(...) { } |
| 12 |
|
| 13 |
namespace PR28080 { |
| 14 |
struct S; // expected-note {{forward declaration}} |
| 15 |
#if __cplusplus >= 201703L |
| 16 |
// expected-error@+3 {{ISO C++17 does not allow dynamic exception specifications}} |
| 17 |
// expected-note@+2 {{use 'noexcept(false)' instead}} |
| 18 |
#endif |
| 19 |
void fn() throw(S); // expected-warning {{incomplete type}} expected-note{{previous declaration}} |
| 20 |
void fn() throw(); // expected-warning {{does not match previous declaration}} |
| 21 |
} |
| 22 |
|
| 23 |
template <typename T> struct FooPtr { |
| 24 |
template <typename U> FooPtr(U *p) : m_pT(nullptr) {} |
| 25 |
|
| 26 |
template <> |
| 27 |
// FIXME: It would be better if this note pointed at the primary template |
| 28 |
// above. |
| 29 |
// expected-note@+1 {{previous declaration is here}} |
| 30 |
FooPtr(T *pInterface) throw() // expected-warning {{exception specification in declaration does not match previous declaration}} |
| 31 |
: m_pT(pInterface) {} |
| 32 |
|
| 33 |
T *m_pT; |
| 34 |
}; |
| 35 |
struct Bar {}; |
| 36 |
template struct FooPtr<Bar>; // expected-note {{requested here}} |