2 /* Test we diagnose accessing elements of atomic structures or unions,
3 which is undefined behavior (C11 6.5.2.3#5). */
4 /* { dg-do compile } */
5 /* { dg-options "-std=c11 -pedantic-errors" } */
11 fn1 (_Atomic
struct S p
)
14 return p
.x
+ e
; /* { dg-warning "accessing a member .x. of an atomic structure" } */
18 fn2 (_Atomic
struct S
*p
)
21 return p
->x
+ e
; /* { dg-warning "accessing a member .x. of an atomic structure" } */
25 fn3 (_Atomic
struct S p
, int x
)
27 p
.x
= x
; /* { dg-warning "accessing a member .x. of an atomic structure" } */
31 fn4 (_Atomic
struct S
*p
, int x
)
33 p
->x
= x
; /* { dg-warning "accessing a member .x. of an atomic structure" } */
37 fn5 (_Atomic
struct S p
)
39 /* This is OK: Members can be safely accessed using a non-atomic
40 object which is assigned to or from the atomic object. */
46 fn6 (_Atomic
struct S
*p
)
53 fn7 (_Atomic
union U p
)
56 return p
.x
+ e
; /* { dg-warning "accessing a member .x. of an atomic union" } */
60 fn8 (_Atomic
union U
*p
)
63 return p
->x
+ e
; /* { dg-warning "accessing a member .x. of an atomic union" } */
67 fn9 (_Atomic
union U p
, int x
)
69 p
.x
= x
; /* { dg-warning "accessing a member .x. of an atomic union" } */
73 fn10 (_Atomic
union U
*p
, int x
)
75 p
->x
= x
; /* { dg-warning "accessing a member .x. of an atomic union" } */
79 fn11 (_Atomic
union U p
)
81 /* This is OK: Members can be safely accessed using a non-atomic
82 object which is assigned to or from the atomic object. */
88 fn12 (_Atomic
union U
*p
)