1 /* { dg-do compile } */
2 /* { dg-options "-O -Wall" } */
3 
4 /* C99 6.5.2.3 Structure and union members.
5    If the first expression has qualified type, the result has the so-qualified
6    version of the type of the designated member.  */
7 
8 struct s {_Decimal32 d32; const _Decimal64 d64;};
9 struct sv { volatile _Decimal32 d32; volatile _Decimal64 d64; };
10 union u
11 {
12   const _Decimal64 d64;
13   _Decimal32 d32;
14   const struct s cs;
15 };
16 
17 struct s s;
18 struct sv sv;
19 const struct s cs;
20 
21 union u u;
22 const union u cu;
23 
g(struct s s)24 struct s g (struct s s)
25 {
26   return s;
27 }
28 
h(union u u)29 union u h (union u u)
30 {
31   return u;
32 }
33 
f()34 void f()
35 {
36   cs.d32 = 1.23dd; /* { dg-error "assignment of member 'd32' in read-only object" } */
37   cs.d64 = 1.23df; /* { dg-error "assignment of member 'd64' in read-only object" } */
38   s.d64 = 1.23df;  /* { dg-error "assignment of read-only member" } */
39 
40   s.d32 = 1.23dd;
41   u.d32 = 1.23dd;
42 
43   u.d64 = 1.23df;    /* { dg-error "assignment of read-only member" } */
44   u.cs.d32 = 1.23dd; /* { dg-error "assignment of member 'd32' in read-only object" } */
45   u.cs.d64 = 1.23df; /* { dg-error "assignment of member 'd64' in read-only object" } */
46 
47   cu.d32 = 1.23dd;   /* { dg-error "assignment of member 'd32' in read-only object" } */
48 
49   cu.d64 = 1.23df;    /* { dg-error "assignment of member 'd64' in read-only object" } */
50   cu.cs.d32 = 1.23dd; /* { dg-error "assignment of member 'd32' in read-only object" } */
51   cu.cs.d64 = 1.23df; /* { dg-error "assignment of member 'd64' in read-only object" } */
52 
53   /* f().x is a valid postfix expression but is not an lvalue if
54      function f() returning a structure or union.  */
55   g(s).d32 = 1.23dd;  /* { dg-error "lvalue required" } */
56   h(u).d64 = 1.23df;  /* { dg-error "lvalue required" } */
57 
58   /* Test assignment to volatile structure members.  */
59   sv.d32 = 1.1df;
60   sv.d64 = 1.1dd;
61 }
62 
63