blob: 4e6d156dfa9ff55b0bae8bf06ece3ae6acc5f62c [file] [log] [blame]
Douglas Gregor94d96292011-01-19 20:34:17 +00001template<typename ...Args>
2int f(Args ...args) {
3 return sizeof...(args) + sizeof...(Args);
4}
5
Argyrios Kyrtzidis427964e2011-08-15 22:40:24 +00006void test() {
7 int a;
8 decltype(a) b;
Douglas Gregor4ca8ac22012-02-24 07:38:34 +00009
10 typedef int Integer;
11 typedef float Float;
12 typedef bool Bool;
13 bool b2 = __is_trivially_constructible(Integer, Float, Bool);
Argyrios Kyrtzidis427964e2011-08-15 22:40:24 +000014}
15
Argyrios Kyrtzidis5a56e1b2013-02-08 19:27:23 +000016typedef int Int;
17
18class B {
19 virtual void foo(Int);
20};
21
22class S : public B {
23 virtual void foo(Int) override;
24};
25
Argyrios Kyrtzidise825cf32013-09-11 23:23:27 +000026// Need std::initializer_list
27namespace std {
28 typedef decltype(sizeof(int)) size_t;
29
30 // libc++'s implementation
31 template <class _E>
32 class initializer_list
33 {
34 const _E* __begin_;
35 size_t __size_;
36
37 initializer_list(const _E* __b, size_t __s)
38 : __begin_(__b),
39 __size_(__s)
40 {}
41
42 public:
43 typedef _E value_type;
44 typedef const _E& reference;
45 typedef const _E& const_reference;
46 typedef size_t size_type;
47
48 typedef const _E* iterator;
49 typedef const _E* const_iterator;
50
51 initializer_list() : __begin_(nullptr), __size_(0) {}
52
53 size_t size() const {return __size_;}
54 const _E* begin() const {return __begin_;}
55 const _E* end() const {return __begin_ + __size_;}
56 };
57}
58
59struct Foo {
60 Foo(std::initializer_list<int> il);
61};
62
63void test2() {
64 Foo{10};
65}
66
Argyrios Kyrtzidis5a56e1b2013-02-08 19:27:23 +000067
Richard Smith762bb9d2011-10-13 22:29:44 +000068// RUN: c-index-test -test-annotate-tokens=%s:1:1:5:1 -fno-delayed-template-parsing -std=c++11 %s | FileCheck %s
Douglas Gregor42b29842011-10-05 19:00:14 +000069// CHECK: Identifier: "args" [3:20 - 3:24] SizeOfPackExpr=args:2:15
Douglas Gregor94d96292011-01-19 20:34:17 +000070// CHECK: Identifier: "Args" [3:38 - 3:42] TypeRef=Args:1:22
Argyrios Kyrtzidis427964e2011-08-15 22:40:24 +000071
Richard Smith762bb9d2011-10-13 22:29:44 +000072// RUN: c-index-test -test-annotate-tokens=%s:8:1:9:1 -std=c++11 %s | FileCheck -check-prefix=CHECK-DECLTYPE %s
Argyrios Kyrtzidis427964e2011-08-15 22:40:24 +000073// CHECK-DECLTYPE: Identifier: "a" [8:12 - 8:13] DeclRefExpr=a:7:7
Douglas Gregor4ca8ac22012-02-24 07:38:34 +000074
75// RUN: c-index-test -test-annotate-tokens=%s:13:1:14:1 -std=c++11 %s | FileCheck -check-prefix=CHECK-TRAIT %s
76// CHECK-TRAIT: Identifier: "Integer" [13:42 - 13:49] TypeRef=Integer:10:15
77// CHECK-TRAIT: Identifier: "Float" [13:51 - 13:56] TypeRef=Float:11:17
78// CHECK-TRAIT: Identifier: "Bool" [13:58 - 13:62] TypeRef=Bool:12:16
79
Argyrios Kyrtzidis5a56e1b2013-02-08 19:27:23 +000080// RUN: c-index-test -test-annotate-tokens=%s:16:1:24:1 -std=c++11 %s | FileCheck -check-prefix=CHECK-WITH-OVERRIDE %s
81// CHECK-WITH-OVERRIDE: Keyword: "virtual" [19:2 - 19:9] CXXMethod=foo:19:15 (virtual)
82// CHECK-WITH-OVERRIDE: Keyword: "void" [19:10 - 19:14] CXXMethod=foo:19:15 (virtual)
83// CHECK-WITH-OVERRIDE: Identifier: "foo" [19:15 - 19:18] CXXMethod=foo:19:15 (virtual)
84// CHECK-WITH-OVERRIDE: Punctuation: "(" [19:18 - 19:19] CXXMethod=foo:19:15 (virtual)
85// CHECK-WITH-OVERRIDE: Identifier: "Int" [19:19 - 19:22] TypeRef=Int:16:13
86// CHECK-WITH-OVERRIDE: Punctuation: ")" [19:22 - 19:23] ParmDecl=:19:22 (Definition)
87// CHECK-WITH-OVERRIDE: Punctuation: ";" [19:23 - 19:24] ClassDecl=B:18:7 (Definition)
88// CHECK-WITH-OVERRIDE: Keyword: "virtual" [23:3 - 23:10] CXXMethod=foo:23:16 (virtual) [Overrides @19:15]
89// CHECK-WITH-OVERRIDE: Keyword: "void" [23:11 - 23:15] CXXMethod=foo:23:16 (virtual) [Overrides @19:15]
90// CHECK-WITH-OVERRIDE: Identifier: "foo" [23:16 - 23:19] CXXMethod=foo:23:16 (virtual) [Overrides @19:15]
91// CHECK-WITH-OVERRIDE: Punctuation: "(" [23:19 - 23:20] CXXMethod=foo:23:16 (virtual) [Overrides @19:15]
92// CHECK-WITH-OVERRIDE: Identifier: "Int" [23:20 - 23:23] TypeRef=Int:16:13
93// CHECK-WITH-OVERRIDE: Punctuation: ")" [23:23 - 23:24] ParmDecl=:23:23 (Definition)
94// CHECK-WITH-OVERRIDE: Keyword: "override" [23:25 - 23:33] attribute(override)=
95// CHECK-WITH-OVERRIDE: Punctuation: ";" [23:33 - 23:34] ClassDecl=S:22:7 (Definition)
Argyrios Kyrtzidise825cf32013-09-11 23:23:27 +000096
97// RUN: c-index-test -test-annotate-tokens=%s:64:1:65:1 -std=c++11 %s | FileCheck -check-prefix=CHECK-INITLIST %s
98// CHECK-INITLIST: Identifier: "Foo" [64:3 - 64:6] TypeRef=struct Foo:59:8