blob: a9b8d2b23cb50f48d81a0961efdbdc840250ae5d [file] [log] [blame]
David Majnemerd9b1a4f2015-11-04 03:40:30 +00001// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
2
David Majnemer5088cdf2015-11-05 01:01:47 +00003static_assert(__has_builtin(__make_integer_seq), "");
4
David Majnemerd9b1a4f2015-11-04 03:40:30 +00005template <class T, T... I>
6struct Seq {
7 static constexpr T PackSize = sizeof...(I);
8};
9
10template <typename T, T N>
11using MakeSeq = __make_integer_seq<Seq, T, N>;
12
13static_assert(__is_same(MakeSeq<int, 0>, Seq<int>), "");
14static_assert(__is_same(MakeSeq<int, 1>, Seq<int, 0>), "");
15static_assert(__is_same(MakeSeq<int, 2>, Seq<int, 0, 1>), "");
16static_assert(__is_same(MakeSeq<int, 3>, Seq<int, 0, 1, 2>), "");
17static_assert(__is_same(MakeSeq<int, 4>, Seq<int, 0, 1, 2, 3>), "");
18
19static_assert(__is_same(MakeSeq<unsigned int, 0U>, Seq<unsigned int>), "");
20static_assert(__is_same(MakeSeq<unsigned int, 1U>, Seq<unsigned int, 0U>), "");
21static_assert(__is_same(MakeSeq<unsigned int, 2U>, Seq<unsigned int, 0U, 1U>), "");
22static_assert(__is_same(MakeSeq<unsigned int, 3U>, Seq<unsigned int, 0U, 1U, 2U>), "");
23static_assert(__is_same(MakeSeq<unsigned int, 4U>, Seq<unsigned int, 0U, 1U, 2U, 3U>), "");
24
25static_assert(__is_same(MakeSeq<long long, 0LL>, Seq<long long>), "");
26static_assert(__is_same(MakeSeq<long long, 1LL>, Seq<long long, 0LL>), "");
27static_assert(__is_same(MakeSeq<long long, 2LL>, Seq<long long, 0LL, 1LL>), "");
28static_assert(__is_same(MakeSeq<long long, 3LL>, Seq<long long, 0LL, 1LL, 2LL>), "");
29static_assert(__is_same(MakeSeq<long long, 4LL>, Seq<long long, 0LL, 1LL, 2LL, 3LL>), "");
30
31static_assert(__is_same(MakeSeq<unsigned long long, 0ULL>, Seq<unsigned long long>), "");
32static_assert(__is_same(MakeSeq<unsigned long long, 1ULL>, Seq<unsigned long long, 0ULL>), "");
33static_assert(__is_same(MakeSeq<unsigned long long, 2ULL>, Seq<unsigned long long, 0ULL, 1ULL>), "");
34static_assert(__is_same(MakeSeq<unsigned long long, 3ULL>, Seq<unsigned long long, 0ULL, 1ULL, 2ULL>), "");
35static_assert(__is_same(MakeSeq<unsigned long long, 4ULL>, Seq<unsigned long long, 0ULL, 1ULL, 2ULL, 3ULL>), "");
36
37template <typename T, T N>
38using ErrorSeq = __make_integer_seq<Seq, T, N>; // expected-error{{must have non-negative sequence length}} \
39 expected-error{{must have integral element type}}
40
41enum Color : int { Red,
42 Green,
43 Blue };
44using illformed1 = ErrorSeq<Color, Blue>; // expected-note{{in instantiation}}
45
46using illformed2 = ErrorSeq<int, -5>;
47
48template <typename T, T N> void f() {}
49__make_integer_seq<f, int, 0> x; // expected-error{{template template parameter must be a class template or type alias template}}
David Majnemerf580dd92016-07-11 05:59:24 +000050
David Majnemerc2406d42016-07-11 17:09:56 +000051__make_integer_seq<__make_integer_seq, int, 10> PR28494; // expected-error{{different template parameters}}
David Majnemerf580dd92016-07-11 05:59:24 +000052// expected-note@make_integer_seq.cpp:* {{template parameter has a different kind}}
53// expected-note@make_integer_seq.cpp:* {{previous template template parameter is here}}