| 1 |
// P2169R4 - A nice placeholder with no name |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
// { dg-options "" } |
| 4 |
|
| 5 |
struct S { |
| 6 |
int _; |
| 7 |
int _; // { dg-warning "name-independent declarations only available with" "" { target c++23_down } } |
| 8 |
}; |
| 9 |
S s = { 1, 2 }; |
| 10 |
|
| 11 |
struct T { |
| 12 |
int _ = 3; |
| 13 |
int _ = 4; // { dg-warning "name-independent declarations only available with" "" { target c++23_down } } |
| 14 |
}; |
| 15 |
T t1; |
| 16 |
#if __cplusplus >= 201402L |
| 17 |
T t2 = { 5, 6 }; |
| 18 |
#endif |
| 19 |
|
| 20 |
struct U { |
| 21 |
int _ (int) { return 1; } |
| 22 |
long _ (long) { return 2; } |
| 23 |
int _; // { dg-warning "name-independent declarations only available with" "" { target c++23_down } } |
| 24 |
}; |
| 25 |
U u = { 7 }; |
| 26 |
|
| 27 |
struct V { |
| 28 |
static int _; |
| 29 |
int _; // { dg-warning "name-independent declarations only available with" "" { target c++23_down } } |
| 30 |
}; |
| 31 |
V v = { 8 }; |
| 32 |
|
| 33 |
struct W : public S, T { int _; }; |
| 34 |
struct X : public S, T { |
| 35 |
int _; |
| 36 |
int _; // { dg-warning "name-independent declarations only available with" "" { target c++23_down } } |
| 37 |
}; |
| 38 |
|
| 39 |
struct Y { |
| 40 |
int _; |
| 41 |
int &foo () { return _; } |
| 42 |
}; |
| 43 |
|
| 44 |
struct Z : public Y { |
| 45 |
int _; |
| 46 |
int bar (); |
| 47 |
}; |
| 48 |
|
| 49 |
int |
| 50 |
Z::bar () |
| 51 |
{ |
| 52 |
return _ + Y::_; |
| 53 |
} |
| 54 |
|
| 55 |
struct A { |
| 56 |
int _; |
| 57 |
void foo () { |
| 58 |
int _; |
| 59 |
_ = 42; |
| 60 |
_ += ({ int _ = 0; _; }); |
| 61 |
} |
| 62 |
}; |
| 63 |
|
| 64 |
struct B { |
| 65 |
union { int _; }; |
| 66 |
void foo () { ++_; }; |
| 67 |
}; |
| 68 |
|
| 69 |
struct C { |
| 70 |
int _; |
| 71 |
union { int x; }; |
| 72 |
void foo () { ++_; }; |
| 73 |
}; |
| 74 |
|
| 75 |
struct D { |
| 76 |
struct { int _; }; |
| 77 |
void foo () { ++_; }; |
| 78 |
}; |
| 79 |
|
| 80 |
struct E { |
| 81 |
struct _ {}; |
| 82 |
int _; |
| 83 |
void foo () { ++_; int _; _ = 5; } |
| 84 |
}; |
| 85 |
typedef struct E::_ E_; |
| 86 |
|
| 87 |
struct F { |
| 88 |
struct _ {}; |
| 89 |
int _; |
| 90 |
int _; // { dg-warning "name-independent declarations only available with" "" { target c++23_down } } |
| 91 |
}; |
| 92 |
typedef struct F::_ F_; |