blob: 71b4578add061e5e9fcb58534a78f3f03e5fe7b9 [file] [log] [blame]
NAKAMURA Takumi6c3e1802012-12-20 03:30:30 +00001// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump -ast-dump-filter Test %s | FileCheck -check-prefix CHECK -strict-whitespace %s
2// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump %s | FileCheck -check-prefix CHECK-TU -strict-whitespace %s
Alexander Kornienkod538ed92012-12-20 02:09:13 +00003
4int TestLocation;
5// CHECK: VarDecl 0x{{[^ ]*}} <{{.*}}:4:1, col:5> TestLocation
6
7struct TestIndent {
8 int x;
9};
10// CHECK: {{^\(RecordDecl.*TestIndent[^()]*$}}
11// CHECK-NEXT: {{^ \(FieldDecl.*x[^()]*\)\)$}}
12
13struct TestChildren {
14 int x;
15 struct y {
16 int z;
17 };
18};
19// CHECK: RecordDecl{{.*}}TestChildren
20// CHECK-NEXT: FieldDecl{{.*}}x
21// CHECK-NEXT: RecordDecl{{.*}}y
22// CHECK-NEXT: FieldDecl{{.*}}z
23
24// CHECK-TU: TranslationUnitDecl
25
26void testLabelDecl() {
27 __label__ TestLabelDecl;
28 TestLabelDecl: goto TestLabelDecl;
29}
30// CHECK: LabelDecl{{.*}} TestLabelDecl
31
32typedef int TestTypedefDecl;
33// CHECK: TypedefDecl{{.*}} TestTypedefDecl 'int'
34
35__module_private__ typedef int TestTypedefDeclPrivate;
36// CHECK: TypedefDecl{{.*}} TestTypedefDeclPrivate 'int' __module_private__
37
38enum TestEnumDecl {
39 testEnumDecl
40};
41// CHECK: EnumDecl{{.*}} TestEnumDecl
42// CHECK-NEXT: EnumConstantDecl{{.*}} testEnumDecl
43
44struct TestEnumDeclAnon {
45 enum {
46 testEnumDeclAnon
47 } e;
48};
49// CHECK: RecordDecl{{.*}} TestEnumDeclAnon
50// CHECK-NEXT: EnumDecl{{.*>$}}
51
52enum TestEnumDeclForward;
53// CHECK: EnumDecl{{.*}} TestEnumDeclForward
54
55__module_private__ enum TestEnumDeclPrivate;
56// CHECK: EnumDecl{{.*}} TestEnumDeclPrivate __module_private__
57
58struct TestRecordDecl {
59 int i;
60};
61// CHECK: RecordDecl{{.*}} struct TestRecordDecl
62// CHECK-NEXT: FieldDecl
63
64struct TestRecordDeclEmpty {
65};
66// CHECK: RecordDecl{{.*}} struct TestRecordDeclEmpty
67
68struct TestRecordDeclAnon1 {
69 struct {
70 } testRecordDeclAnon1;
71};
72// CHECK: RecordDecl{{.*}} struct TestRecordDeclAnon1
73// CHECK-NEXT: RecordDecl{{.*}} struct
74
75struct TestRecordDeclAnon2 {
76 struct {
77 };
78};
79// CHECK: RecordDecl{{.*}} struct TestRecordDeclAnon2
80// CHECK-NEXT: RecordDecl{{.*}} struct
81
82struct TestRecordDeclForward;
83// CHECK: RecordDecl{{.*}} struct TestRecordDeclForward
84
85__module_private__ struct TestRecordDeclPrivate;
86// CHECK: RecordDecl{{.*}} struct TestRecordDeclPrivate __module_private__
87
88enum testEnumConstantDecl {
89 TestEnumConstantDecl,
90 TestEnumConstantDeclInit = 1
91};
92// CHECK: EnumConstantDecl{{.*}} TestEnumConstantDecl 'int'
93// CHECK: EnumConstantDecl{{.*}} TestEnumConstantDeclInit 'int'
94// CHECK-NEXT: IntegerLiteral
95
96struct testIndirectFieldDecl {
97 struct {
98 int TestIndirectFieldDecl;
99 };
100};
101// CHECK: IndirectFieldDecl{{.*}} TestIndirectFieldDecl 'int'
102// CHECK-NEXT: Field{{.*}} ''
103// CHECK-NEXT: Field{{.*}} 'TestIndirectFieldDecl'
104
105int TestFunctionDecl(int x, enum { e } y) {
106 return x;
107}
108// CHECK: FunctionDecl{{.*}} TestFunctionDecl 'int (int, enum {{.*}})'
109// CHECK-NEXT: EnumDecl
110// CHECK-NEXT: EnumConstantDecl{{.*}} e
111// CHECK-NEXT: ParmVarDecl{{.*}} x
112// CHECK-NEXT: ParmVarDecl{{.*}} y
113// CHECK-NEXT: CompoundStmt
114
115int TestFunctionDeclProto(int x);
116// CHECK: FunctionDecl{{.*}} TestFunctionDeclProto 'int (int)'
117// CHECK-NEXT: ParmVarDecl{{.*}} x
118
119extern int TestFunctionDeclSC();
120// CHECK: FunctionDecl{{.*}} TestFunctionDeclSC 'int ()' extern
121
122inline int TestFunctionDeclInline();
123// CHECK: FunctionDecl{{.*}} TestFunctionDeclInline 'int ()' inline
124
125struct testFieldDecl {
126 int TestFieldDecl;
127 int TestFieldDeclWidth : 1;
128 __module_private__ int TestFieldDeclPrivate;
129};
130// CHECK: FieldDecl{{.*}} TestFieldDecl 'int'
131// CHECK: FieldDecl{{.*}} TestFieldDeclWidth 'int'
132// CHECK-NEXT: IntegerLiteral
133// CHECK: FieldDecl{{.*}} TestFieldDeclPrivate 'int' __module_private__
134
135int TestVarDecl;
136// CHECK: VarDecl{{.*}} TestVarDecl 'int'
137
138extern int TestVarDeclSC;
139// CHECK: VarDecl{{.*}} TestVarDeclSC 'int' extern
140
141__thread int TestVarDeclThread;
142// CHECK: VarDecl{{.*}} TestVarDeclThread 'int' __thread
143
144__module_private__ int TestVarDeclPrivate;
145// CHECK: VarDecl{{.*}} TestVarDeclPrivate 'int' __module_private__
146
147int TestVarDeclInit = 0;
148// CHECK: VarDecl{{.*}} TestVarDeclInit 'int'
149// CHECK-NEXT: IntegerLiteral
150
151void testParmVarDecl(int TestParmVarDecl);
152// CHECK: ParmVarDecl{{.*}} TestParmVarDecl 'int'