Devang Patel | 41b6625 | 2007-10-23 20:28:39 +0000 | [diff] [blame] | 1 | // RUN: clang %s -emit-llvm |
2 | |||||
3 | struct { | ||||
4 | int x; | ||||
5 | int y; | ||||
6 | } point; | ||||
7 | |||||
8 | void fn1() { | ||||
9 | point.x = 42; | ||||
10 | } | ||||
11 | |||||
12 | /* Nested member */ | ||||
13 | struct { | ||||
14 | struct { | ||||
15 | int a; | ||||
16 | int b; | ||||
17 | } p1; | ||||
18 | } point2; | ||||
19 | |||||
20 | void fn2() { | ||||
21 | point2.p1.a = 42; | ||||
22 | } | ||||
23 | |||||
24 | /* Indirect reference */ | ||||
25 | typedef struct __sf { | ||||
26 | unsigned char *c; | ||||
27 | short flags; | ||||
28 | } F; | ||||
29 | |||||
30 | typedef struct __sf2 { | ||||
31 | F *ff; | ||||
32 | } F2; | ||||
33 | |||||
34 | int fn3(F2 *c) { | ||||
35 | if (c->ff->c >= 0) | ||||
36 | return 1; | ||||
37 | else | ||||
38 | return 0; | ||||
39 | } | ||||
Devang Patel | 317c716 | 2007-10-23 23:26:46 +0000 | [diff] [blame^] | 40 | |
41 | /* Nested structs */ | ||||
42 | typedef struct NA { | ||||
43 | int data; | ||||
44 | struct NA *next; | ||||
45 | } NA; | ||||
46 | void f1() { A a; } | ||||
47 | |||||
48 | typedef struct NB { | ||||
49 | int d1; | ||||
50 | struct _B2 { | ||||
51 | int d2; | ||||
52 | struct NB *n2; | ||||
53 | } B2; | ||||
54 | } NB; | ||||
55 | |||||
56 | void f2() { NB b; } | ||||
57 |