| 1 |
// { dg-do compile { target c++11 } } |
| 2 |
// { dg-options "" } |
| 3 |
|
| 4 |
struct S { |
| 5 |
static void foo (S); |
| 6 |
void foo (this S); // { dg-warning "explicit object member function only available with" "" { target c++20_down } } |
| 7 |
template <int N, typename T> |
| 8 |
static void bar (S, T); |
| 9 |
template <int N, typename T> |
| 10 |
void bar (this S, T); // { dg-warning "explicit object member function only available with" "" { target c++20_down } } |
| 11 |
static void baz (const S &); |
| 12 |
void baz (this const S &); // { dg-warning "explicit object member function only available with" "" { target c++20_down } } |
| 13 |
}; |
| 14 |
|
| 15 |
void |
| 16 |
S::foo (S) |
| 17 |
{ |
| 18 |
} |
| 19 |
|
| 20 |
void |
| 21 |
S::foo (this S) // { dg-warning "explicit object member function only available with" "" { target c++20_down } } |
| 22 |
{ |
| 23 |
} |
| 24 |
|
| 25 |
template <int N, typename T> |
| 26 |
void |
| 27 |
S::bar (S, T) |
| 28 |
{ |
| 29 |
} |
| 30 |
|
| 31 |
template <int N, typename T> |
| 32 |
void |
| 33 |
S::bar (this S, T) // { dg-warning "explicit object member function only available with" "" { target c++20_down } } |
| 34 |
{ |
| 35 |
} |
| 36 |
|
| 37 |
void |
| 38 |
S::baz (const S &) |
| 39 |
{ |
| 40 |
} |
| 41 |
|
| 42 |
void |
| 43 |
S::baz (this const S &) // { dg-warning "explicit object member function only available with" "" { target c++20_down } } |
| 44 |
{ |
| 45 |
} |
| 46 |
|
| 47 |
void |
| 48 |
qux (S *p) |
| 49 |
{ |
| 50 |
S::foo (*p); |
| 51 |
p->foo (); |
| 52 |
S::bar <5> (*p, 0); |
| 53 |
p->bar <5> (0); |
| 54 |
} |
| 55 |
|
| 56 |
// { dg-final { scan-assembler "_ZN1S3fooES_" } } |
| 57 |
// { dg-final { scan-assembler "_ZNH1S3fooES_" } } |
| 58 |
// { dg-final { scan-assembler "_ZN1S3barILi5EiEEvS_T0_" } } |
| 59 |
// { dg-final { scan-assembler "_ZNH1S3barILi5EiEEvS_T0_" } } |
| 60 |
// { dg-final { scan-assembler "_ZN1S3bazERKS_" } } |
| 61 |
// { dg-final { scan-assembler "_ZNH1S3bazERKS_" } } |