187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s 287d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 387d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainarstatic_assert(__has_builtin(__make_integer_seq), ""); 487d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 587d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainartemplate <class T, T... I> 687d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainarstruct Seq { 787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar static constexpr T PackSize = sizeof...(I); 887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar}; 987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 1087d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainartemplate <typename T, T N> 1187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainarusing MakeSeq = __make_integer_seq<Seq, T, N>; 1287d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 1387d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainarstatic_assert(__is_same(MakeSeq<int, 0>, Seq<int>), ""); 1487d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainarstatic_assert(__is_same(MakeSeq<int, 1>, Seq<int, 0>), ""); 1587d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainarstatic_assert(__is_same(MakeSeq<int, 2>, Seq<int, 0, 1>), ""); 1687d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainarstatic_assert(__is_same(MakeSeq<int, 3>, Seq<int, 0, 1, 2>), ""); 1787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainarstatic_assert(__is_same(MakeSeq<int, 4>, Seq<int, 0, 1, 2, 3>), ""); 1887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 1987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainarstatic_assert(__is_same(MakeSeq<unsigned int, 0U>, Seq<unsigned int>), ""); 2087d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainarstatic_assert(__is_same(MakeSeq<unsigned int, 1U>, Seq<unsigned int, 0U>), ""); 2187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainarstatic_assert(__is_same(MakeSeq<unsigned int, 2U>, Seq<unsigned int, 0U, 1U>), ""); 2287d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainarstatic_assert(__is_same(MakeSeq<unsigned int, 3U>, Seq<unsigned int, 0U, 1U, 2U>), ""); 2387d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainarstatic_assert(__is_same(MakeSeq<unsigned int, 4U>, Seq<unsigned int, 0U, 1U, 2U, 3U>), ""); 2487d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 2587d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainarstatic_assert(__is_same(MakeSeq<long long, 0LL>, Seq<long long>), ""); 2687d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainarstatic_assert(__is_same(MakeSeq<long long, 1LL>, Seq<long long, 0LL>), ""); 2787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainarstatic_assert(__is_same(MakeSeq<long long, 2LL>, Seq<long long, 0LL, 1LL>), ""); 2887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainarstatic_assert(__is_same(MakeSeq<long long, 3LL>, Seq<long long, 0LL, 1LL, 2LL>), ""); 2987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainarstatic_assert(__is_same(MakeSeq<long long, 4LL>, Seq<long long, 0LL, 1LL, 2LL, 3LL>), ""); 3087d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 3187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainarstatic_assert(__is_same(MakeSeq<unsigned long long, 0ULL>, Seq<unsigned long long>), ""); 3287d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainarstatic_assert(__is_same(MakeSeq<unsigned long long, 1ULL>, Seq<unsigned long long, 0ULL>), ""); 3387d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainarstatic_assert(__is_same(MakeSeq<unsigned long long, 2ULL>, Seq<unsigned long long, 0ULL, 1ULL>), ""); 3487d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainarstatic_assert(__is_same(MakeSeq<unsigned long long, 3ULL>, Seq<unsigned long long, 0ULL, 1ULL, 2ULL>), ""); 3587d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainarstatic_assert(__is_same(MakeSeq<unsigned long long, 4ULL>, Seq<unsigned long long, 0ULL, 1ULL, 2ULL, 3ULL>), ""); 3687d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 3787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainartemplate <typename T, T N> 3887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainarusing ErrorSeq = __make_integer_seq<Seq, T, N>; // expected-error{{must have non-negative sequence length}} \ 3987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar expected-error{{must have integral element type}} 4087d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 4187d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainarenum Color : int { Red, 4287d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar Green, 4387d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar Blue }; 4487d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainarusing illformed1 = ErrorSeq<Color, Blue>; // expected-note{{in instantiation}} 4587d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 4687d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainarusing illformed2 = ErrorSeq<int, -5>; 4787d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar 4887d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainartemplate <typename T, T N> void f() {} 4987d948ecccffea9e9e37d0d053b246e2d6d6c47bPirama Arumuga Nainar__make_integer_seq<f, int, 0> x; // expected-error{{template template parameter must be a class template or type alias template}} 504967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar 514967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar__make_integer_seq<__make_integer_seq, int, 10> PR28494; // expected-error{{different template parameters}} 524967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar// expected-note@make_integer_seq.cpp:* {{template parameter has a different kind}} 534967a710c84587c654b56c828382219c3937dacbPirama Arumuga Nainar// expected-note@make_integer_seq.cpp:* {{previous template template parameter is here}} 54