// { dg-do assemble }
|
// { dg-do assemble }
|
// PRMS Id: 9127
|
// PRMS Id: 9127
|
// Bug: members of anonymous unions are not access-controlled.
|
// Bug: members of anonymous unions are not access-controlled.
|
|
|
#include
|
#include
|
|
|
struct Foo {
|
struct Foo {
|
public:
|
public:
|
union {
|
union {
|
long A;
|
long A;
|
void *pX;
|
void *pX;
|
};
|
};
|
union X {
|
union X {
|
long A;
|
long A;
|
void *pX;
|
void *pX;
|
} PUB ;
|
} PUB ;
|
int PUB_A;
|
int PUB_A;
|
protected:
|
protected:
|
union {
|
union {
|
long B; // { dg-error "" } protected
|
long B; // { dg-error "" } protected
|
void *pY; // { dg-error "" } protected
|
void *pY; // { dg-error "" } protected
|
} ;
|
} ;
|
union Y {
|
union Y {
|
long B;
|
long B;
|
void *pY;
|
void *pY;
|
} PRT; // { dg-error "" } protected
|
} PRT; // { dg-error "" } protected
|
int PRT_A; // { dg-error "" } protected
|
int PRT_A; // { dg-error "" } protected
|
private:
|
private:
|
union {
|
union {
|
long C; // { dg-error "" } private
|
long C; // { dg-error "" } private
|
void *pZ; // { dg-error "" } private
|
void *pZ; // { dg-error "" } private
|
};
|
};
|
union Z {
|
union Z {
|
long C;
|
long C;
|
void *pZ;
|
void *pZ;
|
} PRV; // { dg-error "" } private
|
} PRV; // { dg-error "" } private
|
int PRV_A; // { dg-error "" } private
|
int PRV_A; // { dg-error "" } private
|
};
|
};
|
|
|
struct Bar : public Foo {
|
struct Bar : public Foo {
|
public:
|
public:
|
void DoSomething() {
|
void DoSomething() {
|
PUB_A = 0;
|
PUB_A = 0;
|
Foo::A = 0;
|
Foo::A = 0;
|
printf("%x\n",pX);
|
printf("%x\n",pX);
|
Foo::PUB.A = 0;
|
Foo::PUB.A = 0;
|
printf("%x\n",PUB.pX);
|
printf("%x\n",PUB.pX);
|
B = 0;
|
B = 0;
|
printf("%x\n",Foo::pY);
|
printf("%x\n",Foo::pY);
|
PRT_A = 0;
|
PRT_A = 0;
|
PRT.B = 0;
|
PRT.B = 0;
|
printf("%x\n",Foo::PRT.pY);
|
printf("%x\n",Foo::PRT.pY);
|
PRV_A = 0; // { dg-error "" }
|
PRV_A = 0; // { dg-error "" }
|
Foo::C = 0; // { dg-error "" }
|
Foo::C = 0; // { dg-error "" }
|
printf("%x\n",pZ); // { dg-error "" }
|
printf("%x\n",pZ); // { dg-error "" }
|
Foo::PRV.C = 0; // { dg-error "" }
|
Foo::PRV.C = 0; // { dg-error "" }
|
printf("%x\n",PRV.pZ); // { dg-error "" }
|
printf("%x\n",PRV.pZ); // { dg-error "" }
|
}
|
}
|
};
|
};
|
|
|
int main()
|
int main()
|
{
|
{
|
Foo a;
|
Foo a;
|
|
|
a.PUB_A = 0;
|
a.PUB_A = 0;
|
a.A = 0;
|
a.A = 0;
|
printf("%x\n",a.pX);
|
printf("%x\n",a.pX);
|
a.PRT_A = 0; // { dg-error "" }
|
a.PRT_A = 0; // { dg-error "" }
|
a.B = 0; // { dg-error "" }
|
a.B = 0; // { dg-error "" }
|
printf("%x\n",a.pY); // { dg-error "" }
|
printf("%x\n",a.pY); // { dg-error "" }
|
a.PRV_A = 0; // { dg-error "" }
|
a.PRV_A = 0; // { dg-error "" }
|
a.C = 0; // { dg-error "" }
|
a.C = 0; // { dg-error "" }
|
printf("%x\n",a.pZ); // { dg-error "" }
|
printf("%x\n",a.pZ); // { dg-error "" }
|
a.PUB.A = 0;
|
a.PUB.A = 0;
|
printf("%x\n",a.PUB.pX);
|
printf("%x\n",a.PUB.pX);
|
a.PRT.B = 0; // { dg-error "" }
|
a.PRT.B = 0; // { dg-error "" }
|
printf("%x\n",a.PRT.pY); // { dg-error "" }
|
printf("%x\n",a.PRT.pY); // { dg-error "" }
|
a.PRV.C = 0; // { dg-error "" }
|
a.PRV.C = 0; // { dg-error "" }
|
printf("%x\n",a.PRV.pZ); // { dg-error "" }
|
printf("%x\n",a.PRV.pZ); // { dg-error "" }
|
}
|
}
|
|
|