| 1 |
// PR c++/38796 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
|
| 4 |
#define SA(X) static_assert ((X), #X) |
| 5 |
|
| 6 |
struct A |
| 7 |
{ |
| 8 |
A (int); |
| 9 |
A (const A& = 1) = default; // { dg-error "default argument" } |
| 10 |
void operator= (const A&) = default; // { dg-error "defaulted|match" } |
| 11 |
}; |
| 12 |
|
| 13 |
struct B |
| 14 |
{ |
| 15 |
private: |
| 16 |
B() = default; |
| 17 |
}; |
| 18 |
|
| 19 |
SA(__has_trivial_constructor(B)); |
| 20 |
|
| 21 |
struct C |
| 22 |
{ |
| 23 |
protected: |
| 24 |
~C() = default; |
| 25 |
}; |
| 26 |
|
| 27 |
SA(__has_trivial_destructor(C)); |
| 28 |
|
| 29 |
struct D |
| 30 |
{ |
| 31 |
private: |
| 32 |
D& operator= (const D&) = default; |
| 33 |
}; |
| 34 |
|
| 35 |
SA(__has_trivial_assign(D)); |
| 36 |
|
| 37 |
struct E |
| 38 |
{ |
| 39 |
explicit E (const E&) = default; |
| 40 |
}; |
| 41 |
|
| 42 |
SA(__has_trivial_copy(E)); |
| 43 |
|
| 44 |
struct F |
| 45 |
{ |
| 46 |
F(F&) = default; |
| 47 |
}; |
| 48 |
|
| 49 |
struct G: public F |
| 50 |
{ |
| 51 |
G(const G&) = default; // { dg-error "implicitly deleted" "" { target c++17_down } } |
| 52 |
// { dg-warning "implicitly deleted" "" { target c++20 } .-1 } |
| 53 |
}; |
| 54 |
|
| 55 |
struct H |
| 56 |
{ |
| 57 |
virtual ~H() = default; |
| 58 |
}; |