annotate clang/test/CodeGen/union.c @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 1d019706d866
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 %s -emit-llvm -o -
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 union u_tag {
anatofuz
parents:
diff changeset
4 int a;
anatofuz
parents:
diff changeset
5 float b;
anatofuz
parents:
diff changeset
6 } u;
anatofuz
parents:
diff changeset
7
anatofuz
parents:
diff changeset
8 void f() {
anatofuz
parents:
diff changeset
9 u.b = 11;
anatofuz
parents:
diff changeset
10 }
anatofuz
parents:
diff changeset
11
anatofuz
parents:
diff changeset
12 float get_b(union u_tag *my_u) {
anatofuz
parents:
diff changeset
13 return my_u->b;
anatofuz
parents:
diff changeset
14 }
anatofuz
parents:
diff changeset
15
anatofuz
parents:
diff changeset
16 int f2( float __x ) {
anatofuz
parents:
diff changeset
17 union{
anatofuz
parents:
diff changeset
18 float __f;
anatofuz
parents:
diff changeset
19 unsigned int __u;
anatofuz
parents:
diff changeset
20 }__u;
anatofuz
parents:
diff changeset
21 return (int)(__u.__u >> 31);
anatofuz
parents:
diff changeset
22 }
anatofuz
parents:
diff changeset
23
anatofuz
parents:
diff changeset
24 typedef union { int i; int *j; } value;
anatofuz
parents:
diff changeset
25
anatofuz
parents:
diff changeset
26 int f3(value v) {
anatofuz
parents:
diff changeset
27 return *v.j;
anatofuz
parents:
diff changeset
28 }
anatofuz
parents:
diff changeset
29
anatofuz
parents:
diff changeset
30 enum E9 { one, two };
anatofuz
parents:
diff changeset
31 union S65 { enum E9 a; } ; union S65 s65;
anatofuz
parents:
diff changeset
32 void fS65() { enum E9 e = s65.a; }
anatofuz
parents:
diff changeset
33
anatofuz
parents:
diff changeset
34 typedef union{
anatofuz
parents:
diff changeset
35 unsigned char x[65536];
anatofuz
parents:
diff changeset
36 } q;
anatofuz
parents:
diff changeset
37 int qfunc() {q buf; unsigned char* x = buf.x;}
anatofuz
parents:
diff changeset
38
anatofuz
parents:
diff changeset
39 union RR {_Bool a : 1;} RRU;
anatofuz
parents:
diff changeset
40 int RRF(void) {return RRU.a;}
anatofuz
parents:
diff changeset
41
anatofuz
parents:
diff changeset
42 // PR6164
anatofuz
parents:
diff changeset
43 typedef union T0 { unsigned int : 0; } T0;
anatofuz
parents:
diff changeset
44 T0 t0;
anatofuz
parents:
diff changeset
45
anatofuz
parents:
diff changeset
46 union { int large_bitfield: 31; char c } u2;
anatofuz
parents:
diff changeset
47
anatofuz
parents:
diff changeset
48 struct dt_t_s {
anatofuz
parents:
diff changeset
49 union {
anatofuz
parents:
diff changeset
50 long long u : 56;
anatofuz
parents:
diff changeset
51 } __attribute__((packed));
anatofuz
parents:
diff changeset
52 };
anatofuz
parents:
diff changeset
53 struct {
anatofuz
parents:
diff changeset
54 struct {
anatofuz
parents:
diff changeset
55 struct {
anatofuz
parents:
diff changeset
56 struct dt_t_s t;
anatofuz
parents:
diff changeset
57 };
anatofuz
parents:
diff changeset
58 };
anatofuz
parents:
diff changeset
59 } a;