* gcc.dg/torture/stackalign/builtin-apply-2.c: Fix skip-if syntax.
[official-gcc.git] / gcc / testsuite / gcc.dg / dfp / struct-union.c
blob956fdcf2158357f5f6db8a187c3e53f9d14b24a7
1 /* { dg-do compile } */
2 /* { dg-options "-O -Wall" } */
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. */
8 struct s {_Decimal32 d32; const _Decimal64 d64;};
9 struct sv { volatile _Decimal32 d32; volatile _Decimal64 d64; };
10 union u
12 const _Decimal64 d64;
13 _Decimal32 d32;
14 const struct s cs;
17 struct s s;
18 struct sv sv;
19 const struct s cs;
21 union u u;
22 const union u cu;
24 struct s g (struct s s)
26 return s;
29 union u h (union u u)
31 return u;
34 void f()
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" } */
40 s.d32 = 1.23dd;
41 u.d32 = 1.23dd;
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" } */
47 cu.d32 = 1.23dd; /* { dg-error "assignment of member 'd32' in read-only object" } */
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" } */
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" } */
58 /* Test assignment to volatile structure members. */
59 sv.d32 = 1.1df;
60 sv.d64 = 1.1dd;