| 1 |
// { dg-options "-pedantic-errors -std=c++98" } |
| 2 |
// { dg-do assemble } |
| 3 |
// g++ 1.36.1 bug 900119_01 |
| 4 |
|
| 5 |
// g++ allows initializers to be included in the declaration of members |
| 6 |
// of classes, structs, unions (even when -pedantic is used). |
| 7 |
|
| 8 |
// This is not allowed by the C++ 2.0 Reference Manual or by Cfront 2.0. |
| 9 |
|
| 10 |
// keywords: member declaration, member initialization |
| 11 |
|
| 12 |
// { dg-prune-output "is a static data member" } |
| 13 |
|
| 14 |
int global_int; |
| 15 |
|
| 16 |
class class0 { |
| 17 |
public: |
| 18 |
int class0_member_0 = 99; /* { dg-error "" } */ |
| 19 |
static int class0_member_1 = 99; /* { dg-error "" } */ |
| 20 |
int &class0_member_2 = global_int; /* { dg-error "" } */ |
| 21 |
|
| 22 |
class0 () : class0_member_2 (global_int) { } |
| 23 |
}; |
| 24 |
|
| 25 |
|
| 26 |
struct struct0 { |
| 27 |
int struct0_member_0 = 99; /* { dg-error "" } */ |
| 28 |
static int struct0_member_1 = 99; /* { dg-error "" } */ |
| 29 |
int &struct0_member_2 = global_int; /* { dg-error "" } */ |
| 30 |
|
| 31 |
struct0 () : struct0_member_2 (global_int) { } |
| 32 |
}; |
| 33 |
|
| 34 |
// g++ does not allow unions to have more than one member with an initializer |
| 35 |
|
| 36 |
union union0 { |
| 37 |
int union0_member_0 = 99; /* { dg-error "" } */ |
| 38 |
}; |
| 39 |
|
| 40 |
union union1 { |
| 41 |
//static int union1_member_0 = 99; /* definitely illegal (9.5) */ |
| 42 |
}; |
| 43 |
|
| 44 |
union union2 { |
| 45 |
int &union2_member_0 = global_int; /* { dg-error "" } */ |
| 46 |
|
| 47 |
union2 () : union2_member_0 (global_int) { } |
| 48 |
}; |
| 49 |
|
| 50 |
int main () { return 0; } |