OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.old-deja/] [g++.jason/] [access23.C] - Blame information for rev 699

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 699 jeremybenn
// { dg-do assemble  }
2
// PRMS Id: 9127
3
// Bug: members of anonymous unions are not access-controlled.
4
 
5
#include 
6
 
7
struct Foo {
8
public:
9
  union {
10
    long A;
11
    void *pX;
12
  };
13
  union X {
14
    long A;
15
    void *pX;
16
  } PUB ;
17
  int PUB_A;
18
protected:
19
  union {
20
    long B; // { dg-error "" } protected
21
    void *pY; // { dg-error "" } protected
22
  } ;
23
  union Y {
24
    long B;
25
    void *pY;
26
  } PRT; // { dg-error "" } protected
27
  int PRT_A; // { dg-error "" } protected
28
private:
29
  union {
30
    long C; // { dg-error "" } private
31
    void *pZ; // { dg-error "" } private
32
  };
33
  union Z {
34
    long C;
35
    void *pZ;
36
  } PRV; // { dg-error "" } private
37
  int PRV_A; // { dg-error "" } private
38
};
39
 
40
struct Bar : public Foo {
41
public:
42
  void DoSomething() {
43
    PUB_A = 0;
44
    Foo::A = 0;
45
    printf("%x\n",pX);
46
    Foo::PUB.A = 0;
47
    printf("%x\n",PUB.pX);
48
    B = 0;
49
    printf("%x\n",Foo::pY);
50
    PRT_A = 0;
51
    PRT.B = 0;
52
    printf("%x\n",Foo::PRT.pY);
53
    PRV_A = 0;                  // { dg-error "" }
54
    Foo::C = 0;                 // { dg-error "" }
55
    printf("%x\n",pZ);          // { dg-error "" }
56
    Foo::PRV.C = 0;             // { dg-error "" }
57
    printf("%x\n",PRV.pZ);      // { dg-error "" }
58
  }
59
};
60
 
61
int main()
62
{
63
  Foo a;
64
 
65
  a.PUB_A = 0;
66
  a.A = 0;
67
  printf("%x\n",a.pX);
68
  a.PRT_A = 0;                  // { dg-error "" }
69
  a.B = 0;                      // { dg-error "" }
70
  printf("%x\n",a.pY);          // { dg-error "" }
71
  a.PRV_A = 0;                  // { dg-error "" }
72
  a.C = 0;                      // { dg-error "" }
73
  printf("%x\n",a.pZ);          // { dg-error "" }
74
  a.PUB.A = 0;
75
  printf("%x\n",a.PUB.pX);
76
  a.PRT.B = 0;                  // { dg-error "" }
77
  printf("%x\n",a.PRT.pY);      // { dg-error "" }
78
  a.PRV.C = 0;                  // { dg-error "" }
79
  printf("%x\n",a.PRV.pZ);      // { dg-error "" }
80
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.