| 1 |
// RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -std=c++11 %s |
| 2 |
|
| 3 |
namespace MissingOnTemplate { |
| 4 |
template<typename T> void foo(T) noexcept(true); // expected-note {{previous}} |
| 5 |
template<typename T> void foo(T); // expected-error {{missing exception specification 'noexcept(true)'}} |
| 6 |
void test() { foo(0); } |
| 7 |
} |
| 8 |
|
| 9 |
struct UseBeforeComplete1 { |
| 10 |
~UseBeforeComplete1(); // expected-note {{previous}} |
| 11 |
struct X { |
| 12 |
friend UseBeforeComplete1::~UseBeforeComplete1() noexcept; // expected-warning {{previously declared with an implicit}} |
| 13 |
}; |
| 14 |
}; |
| 15 |
|
| 16 |
struct ThrowingDtor { ~ThrowingDtor() noexcept(false); }; |
| 17 |
struct UseBeforeComplete2 { |
| 18 |
~UseBeforeComplete2(); // expected-note {{previous}} |
| 19 |
struct X { |
| 20 |
friend UseBeforeComplete2::~UseBeforeComplete2() noexcept; // expected-error {{does not match previous}} |
| 21 |
}; |
| 22 |
ThrowingDtor td; |
| 23 |
}; |
| 24 |
|
| 25 |
struct UseBeforeComplete3 { |
| 26 |
~UseBeforeComplete3(); |
| 27 |
struct X { |
| 28 |
friend UseBeforeComplete3::~UseBeforeComplete3(); // ok, implicitly noexcept(true) |
| 29 |
}; |
| 30 |
}; |
| 31 |
static_assert(noexcept(UseBeforeComplete3()), ""); |
| 32 |
|
| 33 |
struct UseBeforeComplete4 { |
| 34 |
~UseBeforeComplete4(); |
| 35 |
struct X { |
| 36 |
friend UseBeforeComplete4::~UseBeforeComplete4(); // ok, implicitly noexcept(false) |
| 37 |
}; |
| 38 |
ThrowingDtor td; |
| 39 |
}; |
| 40 |
static_assert(!noexcept(UseBeforeComplete4()), ""); |
| 41 |
|
| 42 |
namespace AssignmentOp { |
| 43 |
struct D1; |
| 44 |
struct D2; |
| 45 |
struct B { |
| 46 |
B &operator=(const B&); |
| 47 |
virtual D1 &operator=(const D1&) noexcept; // expected-note {{overridden}} |
| 48 |
virtual D2 &operator=(const D2&) noexcept; // expected-note {{overridden}} |
| 49 |
}; |
| 50 |
struct D1 : B {}; // expected-error {{more lax}} |
| 51 |
struct D2 : B { |
| 52 |
D2 &operator=(const D2&); // expected-error {{more lax}} |
| 53 |
}; |
| 54 |
} |
| 55 |
|
| 56 |
namespace OverloadedFunctions { |
| 57 |
|
| 58 |
template <typename T> |
| 59 |
void f(T&) noexcept; |
| 60 |
|
| 61 |
template <typename T, int N> |
| 62 |
void f(T (&arr)[N]) noexcept(noexcept(f(*arr))); |
| 63 |
|
| 64 |
template <typename T> |
| 65 |
inline void f(T&) noexcept {} |
| 66 |
|
| 67 |
template <typename T, int N> |
| 68 |
inline void f(T (&arr)[N]) noexcept(noexcept(f(*arr))) {} |
| 69 |
|
| 70 |
void g() { |
| 71 |
int x[1]; |
| 72 |
f(x); |
| 73 |
} |
| 74 |
|
| 75 |
} |