summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.law/union2.C
blob: 37de9eaf0bac5b1dedb020c9ec5219b6e41fae08 (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
// { dg-do assemble  }
// GROUPS passed unions
// anon-union file
// From: gerlek@dat.cse.ogi.edu (Michael Gerlek)
// Date:     Tue, 8 Dec 92 12:56 PST
// Subject:  private anonymous unions have public members? (gcc-2.3.1)
// Message-ID: <m0mzByL-0000hoC@dat.cse.ogi.edu>

class A {
public:
  int x;
private:
  int y;    // { dg-error "" } private
  union {
    int z;  // { dg-error "" } private
  };
};

void f() {
  A a;

  a.x = 0;
  a.y = 1;// { dg-error "" } .*
  a.z = 2;// { dg-error "" } 
}