aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.old-deja/g++.bugs/900119_01.C
blob: 0d181c7eeb8218c4982b72b8a812eb93d17262f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// { dg-options "-pedantic-errors -std=c++98" }
// { dg-do assemble  }
// g++ 1.36.1 bug 900119_01

// g++ allows initializers to be included in the declaration of members
// of classes, structs, unions (even when -pedantic is used).

// This is not allowed by the C++ 2.0 Reference Manual or by Cfront 2.0.

// keywords: member declaration, member initialization

// { dg-prune-output "is a static data member" }

int global_int;

class class0 {
public:
  int class0_member_0 = 99;			/* { dg-error "" }  */
  static int class0_member_1 = 99;		/* { dg-error "" }  */
  int &class0_member_2 = global_int;		/* { dg-error "" }  */

  class0 () : class0_member_2 (global_int) { }
};


struct struct0 {
  int struct0_member_0 = 99;			/* { dg-error "" }  */
  static int struct0_member_1 = 99;		/* { dg-error "" }  */
  int &struct0_member_2 = global_int;		/* { dg-error "" }  */

  struct0 () : struct0_member_2 (global_int) { }
};

// g++ does not allow unions to have more than one member with an initializer

union union0 {
  int union0_member_0 = 99;			/* { dg-error "" }  */
};

union union1 {
  //static int union1_member_0 = 99;		/* definitely illegal (9.5) */
};

union union2 {
  int &union2_member_0 = global_int;		/* { dg-error "" }  */

  union2 () : union2_member_0 (global_int) { }
};

int main () { return 0; }