2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 %s -emit-llvm -o -
|
2007-10-27 03:42:18 +08:00
|
|
|
|
2007-12-12 05:33:16 +08:00
|
|
|
union u_tag {
|
2007-10-27 03:42:18 +08:00
|
|
|
int a;
|
|
|
|
float b;
|
|
|
|
} u;
|
|
|
|
|
|
|
|
void f() {
|
|
|
|
u.b = 11;
|
|
|
|
}
|
|
|
|
|
2007-12-12 05:33:16 +08:00
|
|
|
float get_b(union u_tag *my_u) {
|
|
|
|
return my_u->b;
|
|
|
|
}
|
|
|
|
|
2007-10-27 03:42:18 +08:00
|
|
|
int f2( float __x ) {
|
|
|
|
union{
|
|
|
|
float __f;
|
|
|
|
unsigned int __u;
|
|
|
|
}__u;
|
|
|
|
return (int)(__u.__u >> 31);
|
|
|
|
}
|
2007-12-03 00:57:27 +08:00
|
|
|
|
|
|
|
typedef union { int i; int *j; } value;
|
|
|
|
|
|
|
|
int f3(value v) {
|
|
|
|
return *v.j;
|
|
|
|
}
|
2008-05-08 06:28:29 +08:00
|
|
|
|
|
|
|
enum E9 { one, two };
|
2008-12-07 04:32:39 +08:00
|
|
|
union S65 { enum E9 a; } ; union S65 s65;
|
2008-05-08 06:28:29 +08:00
|
|
|
void fS65() { enum E9 e = s65.a; }
|
|
|
|
|
2008-05-21 21:21:01 +08:00
|
|
|
typedef union{
|
|
|
|
unsigned char x[65536];
|
|
|
|
} q;
|
|
|
|
int qfunc() {q buf; unsigned char* x = buf.x;}
|
|
|
|
|
2008-05-29 19:33:25 +08:00
|
|
|
union RR {_Bool a : 1;} RRU;
|
|
|
|
int RRF(void) {return RRU.a;}
|
|
|
|
|
2010-01-29 02:22:03 +08:00
|
|
|
// PR6164
|
|
|
|
typedef union T0 { unsigned int : 0; } T0;
|
|
|
|
T0 t0;
|
2011-02-28 10:01:38 +08:00
|
|
|
|
|
|
|
union { int large_bitfield: 31; char c } u2;
|
2014-03-01 08:38:40 +08:00
|
|
|
|
|
|
|
struct dt_t_s {
|
|
|
|
union {
|
|
|
|
long long u : 56;
|
|
|
|
} __attribute__((packed));
|
|
|
|
};
|
|
|
|
struct {
|
|
|
|
struct {
|
|
|
|
struct {
|
|
|
|
struct dt_t_s t;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
} a;
|