1f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -emit-llvm -o -
2f4a2713aSLionel Sambuc 
3f4a2713aSLionel Sambuc union u_tag {
4f4a2713aSLionel Sambuc   int a;
5f4a2713aSLionel Sambuc   float b;
6f4a2713aSLionel Sambuc } u;
7f4a2713aSLionel Sambuc 
f()8f4a2713aSLionel Sambuc void f() {
9f4a2713aSLionel Sambuc   u.b = 11;
10f4a2713aSLionel Sambuc }
11f4a2713aSLionel Sambuc 
get_b(union u_tag * my_u)12f4a2713aSLionel Sambuc float get_b(union u_tag *my_u) {
13f4a2713aSLionel Sambuc   return my_u->b;
14f4a2713aSLionel Sambuc }
15f4a2713aSLionel Sambuc 
f2(float __x)16f4a2713aSLionel Sambuc int f2( float __x ) {
17f4a2713aSLionel Sambuc   union{
18f4a2713aSLionel Sambuc     float __f;
19f4a2713aSLionel Sambuc     unsigned int __u;
20f4a2713aSLionel Sambuc   }__u;
21f4a2713aSLionel Sambuc   return (int)(__u.__u >> 31);
22f4a2713aSLionel Sambuc }
23f4a2713aSLionel Sambuc 
24f4a2713aSLionel Sambuc typedef union { int i; int *j; } value;
25f4a2713aSLionel Sambuc 
f3(value v)26f4a2713aSLionel Sambuc int f3(value v) {
27f4a2713aSLionel Sambuc   return *v.j;
28f4a2713aSLionel Sambuc }
29f4a2713aSLionel Sambuc 
30f4a2713aSLionel Sambuc enum E9 { one, two };
31f4a2713aSLionel Sambuc union S65 { enum E9 a; } ; union S65 s65;
fS65()32f4a2713aSLionel Sambuc void fS65() { enum E9 e = s65.a; }
33f4a2713aSLionel Sambuc 
34f4a2713aSLionel Sambuc typedef union{
35f4a2713aSLionel Sambuc   unsigned char x[65536];
36f4a2713aSLionel Sambuc } q;
qfunc()37f4a2713aSLionel Sambuc int qfunc() {q buf; unsigned char* x = buf.x;}
38f4a2713aSLionel Sambuc 
39f4a2713aSLionel Sambuc union RR {_Bool a : 1;} RRU;
RRF(void)40f4a2713aSLionel Sambuc int RRF(void) {return RRU.a;}
41f4a2713aSLionel Sambuc 
42f4a2713aSLionel Sambuc // PR6164
43f4a2713aSLionel Sambuc typedef union T0 { unsigned int : 0; } T0;
44f4a2713aSLionel Sambuc T0 t0;
45f4a2713aSLionel Sambuc 
46f4a2713aSLionel Sambuc union { int large_bitfield: 31; char c } u2;
47*0a6a1f1dSLionel Sambuc 
48*0a6a1f1dSLionel Sambuc struct dt_t_s {
49*0a6a1f1dSLionel Sambuc   union {
50*0a6a1f1dSLionel Sambuc     long long u : 56;
51*0a6a1f1dSLionel Sambuc   } __attribute__((packed));
52*0a6a1f1dSLionel Sambuc };
53*0a6a1f1dSLionel Sambuc struct {
54*0a6a1f1dSLionel Sambuc   struct {
55*0a6a1f1dSLionel Sambuc     struct {
56*0a6a1f1dSLionel Sambuc       struct dt_t_s t;
57*0a6a1f1dSLionel Sambuc     };
58*0a6a1f1dSLionel Sambuc   };
59*0a6a1f1dSLionel Sambuc } a;
60