blob: 7fbf9cc4fb6efdc7deb9006d88c0bab3bca92ec3 [file] [log] [blame]
Douglas Gregorfc8ea232010-01-26 17:06:03 +00001typedef int T;
2struct X { int a, b; };
3void f(void *ptr) {
4 T* t_ptr = (T *)ptr;
5 (void)sizeof(T);
6 /* A comment */
7 struct X x = (struct X){1, 2};
8 void *xx = ptr ? : &x;
9 const char * hello = "Hello";
10}
11
12// RUN: c-index-test -test-annotate-tokens=%s:4:1:9:32 %s | FileCheck %s
Daniel Dunbar8f0bf812010-02-14 08:32:51 +000013// CHECK: Identifier: "T" [4:3 - 4:4] TypeRef=T:1:13
14// CHECK: Punctuation: "*" [4:4 - 4:5]
15// CHECK: Identifier: "t_ptr" [4:6 - 4:11] VarDecl=t_ptr:4:6 (Definition)
16// CHECK: Punctuation: "=" [4:12 - 4:13]
17// CHECK: Punctuation: "(" [4:14 - 4:15]
18// CHECK: Identifier: "T" [4:15 - 4:16] TypeRef=T:1:13
19// CHECK: Punctuation: "*" [4:17 - 4:18]
20// CHECK: Punctuation: ")" [4:18 - 4:19]
21// CHECK: Identifier: "ptr" [4:19 - 4:22] DeclRefExpr=ptr:3:14
22// CHECK: Punctuation: ";" [4:22 - 4:23]
23// CHECK: Punctuation: "(" [5:3 - 5:4]
24// CHECK: Keyword: "void" [5:4 - 5:8]
25// CHECK: Punctuation: ")" [5:8 - 5:9]
26// CHECK: Keyword: "sizeof" [5:9 - 5:15]
27// CHECK: Punctuation: "(" [5:15 - 5:16]
28// CHECK: Identifier: "T" [5:16 - 5:17] TypeRef=T:1:13
29// CHECK: Punctuation: ")" [5:17 - 5:18]
30// CHECK: Punctuation: ";" [5:18 - 5:19]
31// CHECK: Comment: "/* A comment */" [6:3 - 6:18]
32// CHECK: Keyword: "struct" [7:3 - 7:9]
33// CHECK: Identifier: "X" [7:10 - 7:11] TypeRef=struct X:2:8
34// CHECK: Identifier: "x" [7:12 - 7:13] VarDecl=x:7:12 (Definition)
35// CHECK: Punctuation: "=" [7:14 - 7:15]
36// CHECK: Punctuation: "(" [7:16 - 7:17]
37// CHECK: Keyword: "struct" [7:17 - 7:23]
38// CHECK: Identifier: "X" [7:24 - 7:25] TypeRef=struct X:2:8
39// CHECK: Punctuation: ")" [7:25 - 7:26]
40// CHECK: Punctuation: "{" [7:26 - 7:27]
41// CHECK: Literal: "1" [7:27 - 7:28]
42// CHECK: Punctuation: "," [7:28 - 7:29]
43// CHECK: Literal: "2" [7:30 - 7:31]
44// CHECK: Punctuation: "}" [7:31 - 7:32]
45// CHECK: Punctuation: ";" [7:32 - 7:33]
46// CHECK: Keyword: "void" [8:3 - 8:7]
47// CHECK: Punctuation: "*" [8:8 - 8:9]
48// CHECK: Identifier: "xx" [8:9 - 8:11] VarDecl=xx:8:9 (Definition)
49// CHECK: Punctuation: "=" [8:12 - 8:13]
50// CHECK: Identifier: "ptr" [8:14 - 8:17] DeclRefExpr=ptr:3:14
51// CHECK: Punctuation: "?" [8:18 - 8:19]
52// CHECK: Punctuation: ":" [8:20 - 8:21]
53// CHECK: Punctuation: "&" [8:22 - 8:23]
54// CHECK: Identifier: "x" [8:23 - 8:24] DeclRefExpr=x:7:12
55// CHECK: Punctuation: ";" [8:24 - 8:25]
56// CHECK: Keyword: "const" [9:3 - 9:8]
57// CHECK: Keyword: "char" [9:9 - 9:13]
58// CHECK: Punctuation: "*" [9:14 - 9:15]
59// CHECK: Identifier: "hello" [9:16 - 9:21] VarDecl=hello:9:16 (Definition)
60// CHECK: Punctuation: "=" [9:22 - 9:23]
61// CHECK: Literal: ""Hello"" [9:24 - 9:31]
62// CHECK: Punctuation: ";" [9:31 - 9:32]
63// CHECK: Punctuation: "}" [10:1 - 10:2]
Douglas Gregord1eabfb2010-02-27 02:42:25 +000064// RUN: c-index-test -test-annotate-tokens=%s:4:1:165:32 %s | FileCheck %s
65// RUN: c-index-test -test-annotate-tokens=%s:4:1:165:38 %s | FileCheck %s