FSF GCC merge 02/23/03
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.jason / access23.C
blob99e0b4565ce057e6dae542c21ba564c671ecab8b
1 // PRMS Id: 9127
2 // Bug: members of anonymous unions are not access-controlled.
4 #include <stdio.h>
6 struct Foo {
7 public:
8   union {
9     long A;
10     void *pX;
11   };
12   union X {
13     long A;
14     void *pX;
15   } PUB ;
16   int PUB_A;
17 protected:
18   union {
19     long B; // ERROR - protected
20     void *pY; // ERROR - protected
21   } ;
22   union Y {
23     long B;
24     void *pY;
25   } PRT; // ERROR - protected
26   int PRT_A; // ERROR - protected
27 private:
28   union {
29     long C; // ERROR - private
30     void *pZ; // ERROR - private
31   };
32   union Z {
33     long C;  
34     void *pZ;
35   } PRV; // ERROR - private
36   int PRV_A; // ERROR - private
39 struct Bar : public Foo {
40 public:
41   void DoSomething() {
42     PUB_A = 0;
43     Foo::A = 0;
44     printf("%x\n",pX);  
45     Foo::PUB.A = 0;
46     printf("%x\n",PUB.pX);  
47     B = 0;                      
48     printf("%x\n",Foo::pY);  
49     PRT_A = 0;
50     PRT.B = 0;          
51     printf("%x\n",Foo::PRT.pY); 
52     PRV_A = 0;                  // ERROR - 
53     Foo::C = 0;                 // ERROR - 
54     printf("%x\n",pZ);          // ERROR - 
55     Foo::PRV.C = 0;             // ERROR - 
56     printf("%x\n",PRV.pZ);      // ERROR - 
57   }
60 int main()
62   Foo a;
64   a.PUB_A = 0;
65   a.A = 0;
66   printf("%x\n",a.pX);  
67   a.PRT_A = 0;                  // ERROR - 
68   a.B = 0;                      // ERROR - 
69   printf("%x\n",a.pY);          // ERROR - 
70   a.PRV_A = 0;                  // ERROR - 
71   a.C = 0;                      // ERROR - 
72   printf("%x\n",a.pZ);          // ERROR - 
73   a.PUB.A = 0;
74   printf("%x\n",a.PUB.pX);  
75   a.PRT.B = 0;                  // ERROR - 
76   printf("%x\n",a.PRT.pY);      // ERROR - 
77   a.PRV.C = 0;                  // ERROR - 
78   printf("%x\n",a.PRV.pZ);      // ERROR -