1a9d87bc6SDouglas Gregor namespace outer { 2a9d87bc6SDouglas Gregor namespace inner { 3a9d87bc6SDouglas Gregor template<typename T> 4a9d87bc6SDouglas Gregor struct vector { 5a9d87bc6SDouglas Gregor typedef T* iterator; 6a9d87bc6SDouglas Gregor }; 7a9d87bc6SDouglas Gregor } 8a9d87bc6SDouglas Gregor } 9a9d87bc6SDouglas Gregor 10a9d87bc6SDouglas Gregor namespace outer_alias = outer; 11a9d87bc6SDouglas Gregor 12a9d87bc6SDouglas Gregor struct X { }; 13a9d87bc6SDouglas Gregor 14a9d87bc6SDouglas Gregor using outer_alias::inner::vector; 15a9d87bc6SDouglas Gregor 16a9d87bc6SDouglas Gregor struct X_vector : outer_alias::inner::vector<X> { 17a9d87bc6SDouglas Gregor using outer_alias::inner::vector<X>::iterator; 18a9d87bc6SDouglas Gregor }; 19a9d87bc6SDouglas Gregor 2014454807SDouglas Gregor namespace outer { 2114454807SDouglas Gregor namespace inner { 2214454807SDouglas Gregor template<typename T, unsigned N> 2314454807SDouglas Gregor struct array { 2414454807SDouglas Gregor void foo(); 2514454807SDouglas Gregor static int max_size; 2614454807SDouglas Gregor }; 2714454807SDouglas Gregor } 2814454807SDouglas Gregor } 29a9d87bc6SDouglas Gregor 3014454807SDouglas Gregor template<typename T, unsigned N> 3114454807SDouglas Gregor void outer::inner::array<T, N>::foo() { 3214454807SDouglas Gregor } 33a9d87bc6SDouglas Gregor 3414454807SDouglas Gregor template<typename T, unsigned N> 3514454807SDouglas Gregor int outer::inner::array<T, N>::max_size = 17; 3614454807SDouglas Gregor 37f29ba48cSDouglas Gregor template<typename T> 38f29ba48cSDouglas Gregor struct X2 : outer::inner::vector<T> { 39f29ba48cSDouglas Gregor typedef T type; 40f29ba48cSDouglas Gregor using typename outer::inner::vector<type>::iterator; 41f29ba48cSDouglas Gregor using outer::inner::vector<type>::push_back; 42f29ba48cSDouglas Gregor }; 43f29ba48cSDouglas Gregor 4412441b3bSDouglas Gregor namespace outer { 4512441b3bSDouglas Gregor namespace inner { 4612441b3bSDouglas Gregor namespace secret { 4712441b3bSDouglas Gregor } 4812441b3bSDouglas Gregor } 4912441b3bSDouglas Gregor } 5012441b3bSDouglas Gregor 5112441b3bSDouglas Gregor using namespace outer_alias::inner::secret; 52*c05ba2efSDouglas Gregor namespace super_secret = outer_alias::inner::secret; 5312441b3bSDouglas Gregor 54*c05ba2efSDouglas Gregor // RUN: c-index-test -test-annotate-tokens=%s:13:1:53:1 %s | FileCheck %s 55a9d87bc6SDouglas Gregor 56a9d87bc6SDouglas Gregor // CHECK: Keyword: "using" [14:1 - 14:6] UsingDeclaration=vector[4:12] 57a9d87bc6SDouglas Gregor // CHECK: Identifier: "outer_alias" [14:7 - 14:18] NamespaceRef=outer_alias:10:11 58a9d87bc6SDouglas Gregor // CHECK: Punctuation: "::" [14:18 - 14:20] UsingDeclaration=vector[4:12] 59a9d87bc6SDouglas Gregor // CHECK: Identifier: "inner" [14:20 - 14:25] NamespaceRef=inner:2:13 60a9d87bc6SDouglas Gregor // CHECK: Punctuation: "::" [14:25 - 14:27] UsingDeclaration=vector[4:12] 61a9d87bc6SDouglas Gregor // CHECK: Identifier: "vector" [14:27 - 14:33] OverloadedDeclRef=vector[4:12] 62a9d87bc6SDouglas Gregor // CHECK: Punctuation: ";" [14:33 - 14:34] 63a9d87bc6SDouglas Gregor // FIXME: Base specifiers, too 64a9d87bc6SDouglas Gregor // CHECK: Keyword: "using" [17:3 - 17:8] UsingDeclaration=iterator[5:18] 65a9d87bc6SDouglas Gregor // CHECK: Identifier: "outer_alias" [17:9 - 17:20] NamespaceRef=outer_alias:10:11 66a9d87bc6SDouglas Gregor // CHECK: Punctuation: "::" [17:20 - 17:22] UsingDeclaration=iterator[5:18] 67a9d87bc6SDouglas Gregor // CHECK: Identifier: "inner" [17:22 - 17:27] NamespaceRef=inner:2:13 68a9d87bc6SDouglas Gregor // CHECK: Punctuation: "::" [17:27 - 17:29] UsingDeclaration=iterator[5:18] 69a9d87bc6SDouglas Gregor // CHECK: Identifier: "vector" [17:29 - 17:35] TemplateRef=vector:4:12 70a9d87bc6SDouglas Gregor // CHECK: Punctuation: "<" [17:35 - 17:36] UsingDeclaration=iterator[5:18] 71a9d87bc6SDouglas Gregor // CHECK: Identifier: "X" [17:36 - 17:37] TypeRef=struct X:12:8 72a9d87bc6SDouglas Gregor // CHECK: Punctuation: ">" [17:37 - 17:38] UsingDeclaration=iterator[5:18] 73a9d87bc6SDouglas Gregor // CHECK: Punctuation: "::" [17:38 - 17:40] UsingDeclaration=iterator[5:18] 74a9d87bc6SDouglas Gregor // CHECK: Identifier: "iterator" [17:40 - 17:48] OverloadedDeclRef=iterator[5:18] 7514454807SDouglas Gregor 7614454807SDouglas Gregor // FIXME: Check nested-name-specifiers on VarDecl, CXXMethodDecl. 77f29ba48cSDouglas Gregor 78f29ba48cSDouglas Gregor // CHECK: Keyword: "using" [40:3 - 40:8] UsingDeclaration=iterator:40:46 79f29ba48cSDouglas Gregor // CHECK: Keyword: "typename" [40:9 - 40:17] UsingDeclaration=iterator:40:46 80f29ba48cSDouglas Gregor // CHECK: Identifier: "outer" [40:18 - 40:23] NamespaceRef=outer:20:11 81f29ba48cSDouglas Gregor // CHECK: Punctuation: "::" [40:23 - 40:25] UsingDeclaration=iterator:40:46 82f29ba48cSDouglas Gregor // CHECK: Identifier: "inner" [40:25 - 40:30] NamespaceRef=inner:21:13 83f29ba48cSDouglas Gregor // CHECK: Punctuation: "::" [40:30 - 40:32] UsingDeclaration=iterator:40:46 84f29ba48cSDouglas Gregor // CHECK: Identifier: "vector" [40:32 - 40:38] TemplateRef=vector:4:12 85f29ba48cSDouglas Gregor // CHECK: Punctuation: "<" [40:38 - 40:39] UsingDeclaration=iterator:40:46 86f29ba48cSDouglas Gregor // CHECK: Identifier: "type" [40:39 - 40:43] TypeRef=type:39:13 87f29ba48cSDouglas Gregor // CHECK: Punctuation: ">" [40:43 - 40:44] UsingDeclaration=iterator:40:46 88f29ba48cSDouglas Gregor // CHECK: Punctuation: "::" [40:44 - 40:46] UsingDeclaration=iterator:40:46 89f29ba48cSDouglas Gregor // CHECK: Identifier: "iterator" [40:46 - 40:54] UsingDeclaration=iterator:40:46 90f29ba48cSDouglas Gregor // CHECK: Punctuation: ";" [40:54 - 40:55] ClassTemplate=X2:38:8 (Definition) 91f29ba48cSDouglas Gregor // CHECK: Keyword: "using" [41:3 - 41:8] UsingDeclaration=push_back:41:37 92f29ba48cSDouglas Gregor // CHECK: Identifier: "outer" [41:9 - 41:14] NamespaceRef=outer:20:11 93f29ba48cSDouglas Gregor // CHECK: Punctuation: "::" [41:14 - 41:16] UsingDeclaration=push_back:41:37 94f29ba48cSDouglas Gregor // CHECK: Identifier: "inner" [41:16 - 41:21] NamespaceRef=inner:21:13 95f29ba48cSDouglas Gregor // CHECK: Punctuation: "::" [41:21 - 41:23] UsingDeclaration=push_back:41:37 96f29ba48cSDouglas Gregor // CHECK: Identifier: "vector" [41:23 - 41:29] TemplateRef=vector:4:12 97f29ba48cSDouglas Gregor // CHECK: Punctuation: "<" [41:29 - 41:30] UsingDeclaration=push_back:41:37 98f29ba48cSDouglas Gregor // CHECK: Identifier: "type" [41:30 - 41:34] TypeRef=type:39:13 99f29ba48cSDouglas Gregor // CHECK: Punctuation: ">" [41:34 - 41:35] UsingDeclaration=push_back:41:37 100f29ba48cSDouglas Gregor // CHECK: Punctuation: "::" [41:35 - 41:37] UsingDeclaration=push_back:41:37 101f29ba48cSDouglas Gregor // CHECK: Identifier: "push_back" [41:37 - 41:46] UsingDeclaration=push_back:41:37 10212441b3bSDouglas Gregor 10312441b3bSDouglas Gregor // Using directive 10412441b3bSDouglas Gregor // CHECK: Keyword: "using" [51:1 - 51:6] UsingDirective=:51:37 10512441b3bSDouglas Gregor // CHECK: Keyword: "namespace" [51:7 - 51:16] UsingDirective=:51:37 10612441b3bSDouglas Gregor // CHECK: Identifier: "outer_alias" [51:17 - 51:28] NamespaceRef=outer_alias:10:11 10712441b3bSDouglas Gregor // CHECK: Punctuation: "::" [51:28 - 51:30] UsingDirective=:51:37 10812441b3bSDouglas Gregor // CHECK: Identifier: "inner" [51:30 - 51:35] NamespaceRef=inner:45:13 10912441b3bSDouglas Gregor // CHECK: Punctuation: "::" [51:35 - 51:37] UsingDirective=:51:37 11012441b3bSDouglas Gregor // CHECK: Identifier: "secret" [51:37 - 51:43] NamespaceRef=secret:46:15 111*c05ba2efSDouglas Gregor 112*c05ba2efSDouglas Gregor // Namespace alias 113*c05ba2efSDouglas Gregor // CHECK: Keyword: "namespace" [52:1 - 52:10] NamespaceAlias=super_secret:52:11 114*c05ba2efSDouglas Gregor // CHECK: Identifier: "super_secret" [52:11 - 52:23] NamespaceAlias=super_secret:52:11 115*c05ba2efSDouglas Gregor // CHECK: Punctuation: "=" [52:24 - 52:25] NamespaceAlias=super_secret:52:11 116*c05ba2efSDouglas Gregor // CHECK: Identifier: "outer_alias" [52:26 - 52:37] NamespaceRef=outer_alias:10:11 117*c05ba2efSDouglas Gregor // CHECK: Punctuation: "::" [52:37 - 52:39] NamespaceAlias=super_secret:52:11 118*c05ba2efSDouglas Gregor // CHECK: Identifier: "inner" [52:39 - 52:44] NamespaceRef=inner:45:13 119*c05ba2efSDouglas Gregor // CHECK: Punctuation: "::" [52:44 - 52:46] NamespaceAlias=super_secret:52:11 120*c05ba2efSDouglas Gregor // CHECK: Identifier: "secret" [52:46 - 52:52] NamespaceRef=secret:46:15 121*c05ba2efSDouglas Gregor // CHECK: Punctuation: ";" [52:52 - 52:53] 122*c05ba2efSDouglas Gregor 123