xref: /aosp_15_r20/external/clang/test/CodeGenCXX/2005-02-11-AnonymousUnion.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 %s -emit-llvm -o -
2*67e74705SXin Li 
3*67e74705SXin Li // Test anonymous union with members of the same size.
test1(float F)4*67e74705SXin Li int test1(float F) {
5*67e74705SXin Li   union {
6*67e74705SXin Li      float G;
7*67e74705SXin Li      int i;
8*67e74705SXin Li   };
9*67e74705SXin Li   G = F;
10*67e74705SXin Li   return i;
11*67e74705SXin Li }
12*67e74705SXin Li 
13*67e74705SXin Li // test anonymous union with members of differing size.
test2(short F)14*67e74705SXin Li int test2(short F) {
15*67e74705SXin Li   volatile union {
16*67e74705SXin Li      short G;
17*67e74705SXin Li      int i;
18*67e74705SXin Li   };
19*67e74705SXin Li   G = F;
20*67e74705SXin Li   return i;
21*67e74705SXin Li }
22*67e74705SXin Li 
23*67e74705SXin Li // Make sure that normal unions work.  duh :)
24*67e74705SXin Li volatile union U_t {
25*67e74705SXin Li   short S;
26*67e74705SXin Li   int i;
27*67e74705SXin Li } U;
28*67e74705SXin Li 
test3(short s)29*67e74705SXin Li int test3(short s) {
30*67e74705SXin Li   U.S = s;
31*67e74705SXin Li   return U.i;
32*67e74705SXin Li }
33