struct.c revision 7777bb263f215c5251bd354ed82ff1dbe9153336
1// RUN: clang %s -emit-llvm
2
3struct  {
4  int x;
5  int y;
6} point;
7
8void fn1() {
9  point.x = 42;
10}
11
12/* Nested member */
13struct  {
14  struct {
15    int a;
16    int b;
17  } p1;
18} point2;
19
20void fn2() {
21  point2.p1.a = 42;
22}
23
24/* Indirect reference */
25typedef struct __sf {
26 unsigned char *c;
27 short flags;
28} F;
29
30typedef struct __sf2 {
31  F *ff;
32} F2;
33
34int fn3(F2 *c) {
35  if (c->ff->c >= 0)
36    return 1;
37  else
38    return 0;
39}
40
41/* Nested structs */
42typedef struct NA {
43  int data;
44  struct NA *next;
45} NA;
46void f1() {  NA a; }
47
48typedef struct NB {
49  int d1;
50  struct _B2 {
51    int d2;
52    struct NB *n2;
53  } B2;
54} NB;
55
56void f2() { NB b; }
57
58extern NB *f3();
59void f4() {
60  f3()->d1 = 42;
61}
62
63void f5() {
64  (f3())->d1 = 42;
65}
66
67/* Function calls */
68typedef struct {
69  int location;
70  int length;
71} range;
72
73extern range f6();
74void f7()
75{
76  range r = f6();
77}
78
79/* Member expressions */
80typedef struct {
81  range range1;
82  range range2;
83} rangepair;
84
85void f8()
86{
87  rangepair p;
88
89  range r = p.range1;
90}
91
92void f9(range *p)
93{
94  range r = *p;
95}
96
97/* _Bool types */
98
99struct _w
100{
101  short a,b;
102  short c,d;
103  short e,f;
104  short g;
105
106  unsigned int h,i;
107
108  _Bool j,k;
109} ws;
110