2018-02-09 Sebastian Perta <sebastian.perta@renesas.com>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.bugs / 900121_02.C
blob15a6d27f3433846151b1669304c7e9a8cb3d26e7
1 // { dg-do assemble  }
2 // { dg-prune-output "note" }
3 // { dg-prune-output "deleted" }
5 // g++ 1.36.1 bug 900121_02
7 // Assignment of structs is defined as memberwise assignment,
8 // however g++ (1.36.2) and Cfront 2.0 differ on the definition
9 // of assignment for unions.
11 // (NOTE: Stroustrup now says that assignment of unions which contain either
12 // members or sub-members (base classes are not allowed for unions) which
13 // have non-default assignment operators defined for them will be illegal
14 // in future.)
16 // g++ (1.36.2) on the other hand, accepts this program without errors.
18 // keywords: unions, operator=, inheritance, members
20 struct s0 {
22   int i;
24   void operator= (s0 & arg)
25   {
26     this->i = arg.i;
27   }
30 struct s1 {
32   double d;
34   void operator= (s1 & arg)
35   {
36     this->d = arg.d;
37   }
40 union u0 {
41   s0 u0_member_0;               // { dg-error "" } 
42   s1 u0_member_1;               // { dg-error "" } 
45 void function ()
47   u0 u0_object_0;
48   u0 u0_object_1;
50   u0_object_0 = u0_object_1;
53 int main () { return 0; }