Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -emit-llvm -o - |
Devang Patel | abad06c | 2007-10-26 19:42:18 +0000 | [diff] [blame] | 2 | |
Devang Patel | fe2419a | 2007-12-11 21:33:16 +0000 | [diff] [blame] | 3 | union u_tag { |
Devang Patel | abad06c | 2007-10-26 19:42:18 +0000 | [diff] [blame] | 4 | int a; |
5 | float b; | ||||
6 | } u; | ||||
7 | |||||
8 | void f() { | ||||
9 | u.b = 11; | ||||
10 | } | ||||
11 | |||||
Devang Patel | fe2419a | 2007-12-11 21:33:16 +0000 | [diff] [blame] | 12 | float get_b(union u_tag *my_u) { |
13 | return my_u->b; | ||||
14 | } | ||||
15 | |||||
Devang Patel | abad06c | 2007-10-26 19:42:18 +0000 | [diff] [blame] | 16 | int f2( float __x ) { |
17 | union{ | ||||
18 | float __f; | ||||
19 | unsigned int __u; | ||||
20 | }__u; | ||||
21 | return (int)(__u.__u >> 31); | ||||
22 | } | ||||
Seo Sanghyeon | 2de3b3a | 2007-12-02 16:57:27 +0000 | [diff] [blame] | 23 | |
24 | typedef union { int i; int *j; } value; | ||||
25 | |||||
26 | int f3(value v) { | ||||
27 | return *v.j; | ||||
28 | } | ||||
Devang Patel | 5cada6b | 2008-05-07 22:28:29 +0000 | [diff] [blame] | 29 | |
30 | enum E9 { one, two }; | ||||
Anders Carlsson | 663388f | 2008-12-06 20:32:39 +0000 | [diff] [blame] | 31 | union S65 { enum E9 a; } ; union S65 s65; |
Devang Patel | 5cada6b | 2008-05-07 22:28:29 +0000 | [diff] [blame] | 32 | void fS65() { enum E9 e = s65.a; } |
33 | |||||
Eli Friedman | 0ac5957 | 2008-05-21 13:21:01 +0000 | [diff] [blame] | 34 | typedef union{ |
35 | unsigned char x[65536]; | ||||
36 | } q; | ||||
37 | int qfunc() {q buf; unsigned char* x = buf.x;} | ||||
38 | |||||
Eli Friedman | 1e86b34 | 2008-05-29 11:33:25 +0000 | [diff] [blame] | 39 | union RR {_Bool a : 1;} RRU; |
40 | int RRF(void) {return RRU.a;} | ||||
41 |