1762bb9d0ad20320b9f97a841dce57ba5e8e48b07Richard Smith// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -std=c++11 -fblocks -fms-extensions -fsyntax-only -verify %s
2d0937224f383c7cc72c947119380f9713a070c73Douglas Gregor
37536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregortemplate<typename T, typename U> struct pair;
48491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregortemplate<typename ...> struct tuple;
57536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor
67536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor// A parameter pack whose name appears within the pattern of a pack
77536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor// expansion is expanded by that pack expansion. An appearance of the
87536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor// name of a parameter pack is only expanded by the innermost
97536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor// enclosing pack expansion. The pattern of a pack expansion shall
107536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor// name one or more parameter packs that are not expanded by a nested
117536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor// pack expansion.
127536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregortemplate<typename... Types>
137536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregorstruct Expansion {
147536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  typedef pair<Types..., int> expand_with_pacs; // okay
157536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  typedef pair<Types, int...> expand_no_packs;  // expected-error{{pack expansion does not contain any unexpanded parameter packs}}
167536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor  typedef pair<pair<Types..., int>..., int> expand_with_expanded_nested; // expected-error{{pack expansion does not contain any unexpanded parameter packs}}
177536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor};
18d0937224f383c7cc72c947119380f9713a070c73Douglas Gregor
198491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor// All of the parameter packs expanded by a pack expansion shall have
208491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor// the same number of arguments specified.
218491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregortemplate<typename ...Types>
228491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregorstruct ExpansionLengthMismatch {
238491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor  template<typename ...OtherTypes>
248491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor  struct Inner {
258491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor    typedef tuple<pair<Types, OtherTypes>...> type; // expected-error{{pack expansion contains parameter packs 'Types' and 'OtherTypes' that have different lengths (3 vs. 2)}}
268491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor  };
278491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor};
288491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor
298491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas GregorExpansionLengthMismatch<int, long>::Inner<unsigned int, unsigned long>::type
308491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor  *il_pairs;
318491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregortuple<pair<int, unsigned int>, pair<long, unsigned long> >*il_pairs_2 = il_pairs;
328491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor
33dace95b13e2ceb0c3ec8de6babd926dc5114e1e5Douglas GregorExpansionLengthMismatch<short, int, long>::Inner<unsigned int, unsigned long>::type // expected-note{{in instantiation of template class 'ExpansionLengthMismatch<short, int, long>::Inner<unsigned int, unsigned long>' requested here}}
348491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor  *il_pairs_bad;
358491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor
368491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor
37d0937224f383c7cc72c947119380f9713a070c73Douglas Gregor// An appearance of a name of a parameter pack that is not expanded is
38d0937224f383c7cc72c947119380f9713a070c73Douglas Gregor// ill-formed.
39cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor
40cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor// Test for unexpanded parameter packs in each of the type nodes.
41cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregortemplate<typename T, int N, typename ... Types>
42d0937224f383c7cc72c947119380f9713a070c73Douglas Gregorstruct TestPPName
43cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  : public Types, public T  // expected-error{{base type contains unexpanded parameter pack 'Types'}}
44d0937224f383c7cc72c947119380f9713a070c73Douglas Gregor{
45cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // BuiltinType is uninteresting
46cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // FIXME: ComplexType is uninteresting?
47cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // PointerType
489ef75899bae6dd9a4be1252ae9cadcb619c170ffDouglas Gregor  typedef Types *types_pointer; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
49cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor
50cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // BlockPointerType
51cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  typedef Types (^block_pointer_1)(int); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
52cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  typedef int (^block_pointer_2)(Types); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
53cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor
54cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // LValueReferenceType
55cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  typedef Types &lvalue_ref; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
56cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor
57cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // RValueReferenceType
58cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  typedef Types &&rvalue_ref; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
59cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor
60cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // MemberPointerType
61cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  typedef Types TestPPName::* member_pointer_1; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
62cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  typedef int Types::*member_pointer_2; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
63cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor
64cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // ConstantArrayType
65cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  typedef Types constant_array[17]; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
66cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor
67cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // IncompleteArrayType
68cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  typedef Types incomplete_array[]; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
69cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor
70cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // VariableArrayType
71cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  void f(int i) {
72cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor    Types variable_array[i]; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
73cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  }
74cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor
75cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // DependentSizedArrayType
76cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  typedef Types dependent_sized_array[N]; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
77cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor
78cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // DependentSizedExtVectorType
79cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  typedef Types dependent_sized_ext_vector __attribute__((ext_vector_type(N))); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
80cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor
81cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // VectorType is uninteresting
82cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor
83cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // ExtVectorType
84cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  typedef Types ext_vector __attribute__((ext_vector_type(4))); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
85cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor
86cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // FunctionProtoType
87cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  typedef Types (function_type_1)(int); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
88cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  typedef int (function_type_2)(Types); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
89cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor
90cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // FunctionNoProtoType is uninteresting
91cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // UnresolvedUsingType is uninteresting
92cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // ParenType is uninteresting
93cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // TypedefType is uninteresting
94cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor
95cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // TypeOfExprType
96cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  typedef __typeof__((static_cast<Types>(0))) typeof_expr; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
97cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor
98cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // TypeOfType
99cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  typedef __typeof__(Types) typeof_type;  // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
100cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor
101cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // DecltypeType
102cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  typedef decltype((static_cast<Types>(0))) typeof_expr; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
103cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor
104cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // RecordType is uninteresting
105cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // EnumType is uninteresting
106cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // ElaboratedType is uninteresting
107cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor
108cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // TemplateTypeParmType
109cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  typedef Types template_type_parm; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
110cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor
111cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // SubstTemplateTypeParmType is uninteresting
112cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor
113cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // TemplateSpecializationType
114cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  typedef pair<Types, int> template_specialization; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
115cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor
116cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // InjectedClassName is uninteresting.
117cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor
118cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // DependentNameType
119cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  typedef typename Types::type dependent_name; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
120cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor
121cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // DependentTemplateSpecializationType
122cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  typedef typename Types::template apply<int> dependent_name_1; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
123cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  typedef typename T::template apply<Types> dependent_name_2; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
124cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor
125cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // ObjCObjectType is uninteresting
126cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // ObjCInterfaceType is uninteresting
127cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor  // ObjCObjectPointerType is uninteresting
128d0937224f383c7cc72c947119380f9713a070c73Douglas Gregor};
129bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor
130e186269a8a41dbff1ebea2c251048892979d1078Douglas Gregor// FIXME: Test for unexpanded parameter packs in each of the expression nodes.
13110738d36b150aa65206890c1c845cdba076e4200Douglas Gregortemplate<int ...Values>
13210738d36b150aa65206890c1c845cdba076e4200Douglas Gregorvoid test_unexpanded_in_exprs() {
13310738d36b150aa65206890c1c845cdba076e4200Douglas Gregor  // PredefinedExpr is uninteresting
13410738d36b150aa65206890c1c845cdba076e4200Douglas Gregor  // DeclRefExpr
13510738d36b150aa65206890c1c845cdba076e4200Douglas Gregor  Values; // expected-error{{expression contains unexpanded parameter pack 'Values'}}
13610738d36b150aa65206890c1c845cdba076e4200Douglas Gregor  // IntegerLiteral is uninteresting
13710738d36b150aa65206890c1c845cdba076e4200Douglas Gregor  // FloatingLiteral is uninteresting
13810738d36b150aa65206890c1c845cdba076e4200Douglas Gregor  // ImaginaryLiteral is uninteresting
13910738d36b150aa65206890c1c845cdba076e4200Douglas Gregor  // StringLiteral is uninteresting
14010738d36b150aa65206890c1c845cdba076e4200Douglas Gregor  // CharacterLiteral is uninteresting
14110738d36b150aa65206890c1c845cdba076e4200Douglas Gregor  (Values); // expected-error{{expression contains unexpanded parameter pack 'Values'}}
14210738d36b150aa65206890c1c845cdba076e4200Douglas Gregor  // UnaryOperator
14310738d36b150aa65206890c1c845cdba076e4200Douglas Gregor  -Values; // expected-error{{expression contains unexpanded parameter pack 'Values'}}
14410738d36b150aa65206890c1c845cdba076e4200Douglas Gregor  // OffsetOfExpr
14510738d36b150aa65206890c1c845cdba076e4200Douglas Gregor  struct OffsetMe {
14610738d36b150aa65206890c1c845cdba076e4200Douglas Gregor    int array[17];
14710738d36b150aa65206890c1c845cdba076e4200Douglas Gregor  };
14810738d36b150aa65206890c1c845cdba076e4200Douglas Gregor  __builtin_offsetof(OffsetMe, array[Values]); // expected-error{{expression contains unexpanded parameter pack 'Values'}}
14910738d36b150aa65206890c1c845cdba076e4200Douglas Gregor  // FIXME: continue this...
15010738d36b150aa65206890c1c845cdba076e4200Douglas Gregor}
151e186269a8a41dbff1ebea2c251048892979d1078Douglas Gregor
152bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregortemplate<typename ... Types>
153bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregorvoid TestPPNameFunc(int i) {
1549ef75899bae6dd9a4be1252ae9cadcb619c170ffDouglas Gregor  f(static_cast<Types>(i)); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
155bebbe0d9b7568ce43a464286bee49429489ef483Douglas Gregor}
1569ef75899bae6dd9a4be1252ae9cadcb619c170ffDouglas Gregor
15761c4d28e36cd3f1be392cb77f07436d1fa6b0f9fDouglas Gregortemplate<typename T, template<class> class ...Meta>
15861c4d28e36cd3f1be392cb77f07436d1fa6b0f9fDouglas Gregorstruct TestUnexpandedTTP {
15961c4d28e36cd3f1be392cb77f07436d1fa6b0f9fDouglas Gregor  typedef tuple<typename Meta<T>::type> type; // expected-error{{declaration type contains unexpanded parameter pack 'Meta'}}
16061c4d28e36cd3f1be392cb77f07436d1fa6b0f9fDouglas Gregor};
16161c4d28e36cd3f1be392cb77f07436d1fa6b0f9fDouglas Gregor
162a669c534cf414339060868d70d2348fea9ce6c7dDouglas Gregor// Test for unexpanded parameter packs in declarations.
16356c04588ef3cfa1bbc968fd68de2480a4e66971dDouglas Gregortemplate<typename T, typename... Types>
1640b64ba926752110cff1344a46b36e29396cc4d25Peter Collingbourne// FIXME: this should test that the diagnostic reads "type contains..."
165fc038e9ef8ed262724f42597ca5c844de97b1202Eli Friedmanstruct alignas(Types) TestUnexpandedDecls : T{ // expected-error{{expression contains unexpanded parameter pack 'Types'}}
166e186269a8a41dbff1ebea2c251048892979d1078Douglas Gregor  void member_function(Types);  // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
16774e2fc332e07c76d4e69ccbd0e9e47a0bafd3908Douglas Gregor  void member_function () throw(Types); // expected-error{{exception type contains unexpanded parameter pack 'Types'}}
1688ff7e32f9480bf00d8d8476c650907853d1cc354Eli Friedman  void member_function2() noexcept(Types()); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
16956c04588ef3cfa1bbc968fd68de2480a4e66971dDouglas Gregor  operator Types() const; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
170e186269a8a41dbff1ebea2c251048892979d1078Douglas Gregor  Types data_member;  // expected-error{{data member type contains unexpanded parameter pack 'Types'}}
171e186269a8a41dbff1ebea2c251048892979d1078Douglas Gregor  static Types static_data_member; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
172e186269a8a41dbff1ebea2c251048892979d1078Douglas Gregor  unsigned bit_field : static_cast<Types>(0);  // expected-error{{bit-field size contains unexpanded parameter pack 'Types'}}
173399ad970a25efcbfa7111e17f48285a70fba2731Douglas Gregor  static_assert(static_cast<Types>(0), "Boom"); // expected-error{{static assertion contains unexpanded parameter pack 'Types'}}
1740c9e4799fd78d350a037498b2c797f2b2558791cDouglas Gregor
1750c9e4799fd78d350a037498b2c797f2b2558791cDouglas Gregor  enum E0 : Types {  // expected-error{{fixed underlying type contains unexpanded parameter pack 'Types'}}
1760c9e4799fd78d350a037498b2c797f2b2558791cDouglas Gregor    EnumValue = static_cast<Types>(0) // expected-error{{enumerator value contains unexpanded parameter pack 'Types'}}
1770c9e4799fd78d350a037498b2c797f2b2558791cDouglas Gregor  };
17856c04588ef3cfa1bbc968fd68de2480a4e66971dDouglas Gregor
17956c04588ef3cfa1bbc968fd68de2480a4e66971dDouglas Gregor  using typename Types::type; // expected-error{{using declaration contains unexpanded parameter pack 'Types'}}
18056c04588ef3cfa1bbc968fd68de2480a4e66971dDouglas Gregor  using Types::value; // expected-error{{using declaration contains unexpanded parameter pack 'Types'}}
18156c04588ef3cfa1bbc968fd68de2480a4e66971dDouglas Gregor  using T::operator Types; // expected-error{{using declaration contains unexpanded parameter pack 'Types'}}
1826ccab97c17c17f38eb92c7fe02c766508875bd97Douglas Gregor
1836ccab97c17c17f38eb92c7fe02c766508875bd97Douglas Gregor  friend class Types::foo; // expected-error{{friend declaration contains unexpanded parameter pack 'Types'}}
1846ccab97c17c17f38eb92c7fe02c766508875bd97Douglas Gregor  friend void friend_func(Types); // expected-error{{friend declaration contains unexpanded parameter pack 'Types'}}
1856ccab97c17c17f38eb92c7fe02c766508875bd97Douglas Gregor  friend void Types::other_friend_func(int); // expected-error{{friend declaration contains unexpanded parameter pack 'Types'}}
186a31040f16604849b3b1dc36015056c81bae68ad1Douglas Gregor
187a31040f16604849b3b1dc36015056c81bae68ad1Douglas Gregor  void test_initializers() {
188a31040f16604849b3b1dc36015056c81bae68ad1Douglas Gregor    T copy_init = static_cast<Types>(0); // expected-error{{initializer contains unexpanded parameter pack 'Types'}}
1895b9cc5df25c2198f270dd1d5c438fdce70d4051dSebastian Redl    T direct_init(0, static_cast<Types>(0)); // expected-error{{initializer contains unexpanded parameter pack 'Types'}}
190a31040f16604849b3b1dc36015056c81bae68ad1Douglas Gregor    T list_init = { static_cast<Types>(0) }; // expected-error{{initializer contains unexpanded parameter pack 'Types'}}
191a31040f16604849b3b1dc36015056c81bae68ad1Douglas Gregor  }
1926f52675ec400a0ee89ec6214c4845b8ee274304aDouglas Gregor
193fef2189421b89dad5582b6dd7561badd4224d974Peter Collingbourne  T in_class_member_init = static_cast<Types>(0); // expected-error{{initializer contains unexpanded parameter pack 'Types'}}
194fef2189421b89dad5582b6dd7561badd4224d974Peter Collingbourne  TestUnexpandedDecls() :
195fef2189421b89dad5582b6dd7561badd4224d974Peter Collingbourne    Types(static_cast<Types>(0)), // expected-error{{initializer contains unexpanded parameter pack 'Types'}}
196fef2189421b89dad5582b6dd7561badd4224d974Peter Collingbourne    Types(static_cast<Types>(0))...,
197fef2189421b89dad5582b6dd7561badd4224d974Peter Collingbourne    in_class_member_init(static_cast<Types>(0)) {} // expected-error{{initializer contains unexpanded parameter pack 'Types'}}
198fef2189421b89dad5582b6dd7561badd4224d974Peter Collingbourne
1996f52675ec400a0ee89ec6214c4845b8ee274304aDouglas Gregor  void default_function_args(T = static_cast<Types>(0)); // expected-error{{default argument contains unexpanded parameter pack 'Types'}}
2006f52675ec400a0ee89ec6214c4845b8ee274304aDouglas Gregor
2016f52675ec400a0ee89ec6214c4845b8ee274304aDouglas Gregor  template<typename = Types*> // expected-error{{default argument contains unexpanded parameter pack 'Types'}}
2026f52675ec400a0ee89ec6214c4845b8ee274304aDouglas Gregor    struct default_template_args_1;
2036f52675ec400a0ee89ec6214c4845b8ee274304aDouglas Gregor  template<int = static_cast<Types>(0)> // expected-error{{default argument contains unexpanded parameter pack 'Types'}}
2046f52675ec400a0ee89ec6214c4845b8ee274304aDouglas Gregor    struct default_template_args_2;
2056f52675ec400a0ee89ec6214c4845b8ee274304aDouglas Gregor  template<template<typename> class = Types::template apply> // expected-error{{default argument contains unexpanded parameter pack 'Types'}}
2066f52675ec400a0ee89ec6214c4845b8ee274304aDouglas Gregor    struct default_template_args_3;
207781def075d4a486a5b367c6730fe77cb1f721ac1Douglas Gregor
208781def075d4a486a5b367c6730fe77cb1f721ac1Douglas Gregor  template<Types value> // expected-error{{non-type template parameter type contains unexpanded parameter pack 'Types'}}
209781def075d4a486a5b367c6730fe77cb1f721ac1Douglas Gregor  struct non_type_template_param_type;
210a669c534cf414339060868d70d2348fea9ce6c7dDouglas Gregor
211a669c534cf414339060868d70d2348fea9ce6c7dDouglas Gregor  void decls_in_stmts() {
212a669c534cf414339060868d70d2348fea9ce6c7dDouglas Gregor    Types t; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
213a669c534cf414339060868d70d2348fea9ce6c7dDouglas Gregor    for (Types *t = 0; ; ) { } // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
214a669c534cf414339060868d70d2348fea9ce6c7dDouglas Gregor    for (; Types *t = 0; ) { } // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
215ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith    T a[] = { T(), T(), T() };
216ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith    for (Types t : a) { } // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
217a669c534cf414339060868d70d2348fea9ce6c7dDouglas Gregor    switch(Types *t = 0) { } // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
218a669c534cf414339060868d70d2348fea9ce6c7dDouglas Gregor    while(Types *t = 0) { } // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
219a669c534cf414339060868d70d2348fea9ce6c7dDouglas Gregor    if (Types *t = 0) { } // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
220a669c534cf414339060868d70d2348fea9ce6c7dDouglas Gregor    try {
221a669c534cf414339060868d70d2348fea9ce6c7dDouglas Gregor    } catch (Types*) { // expected-error{{exception type contains unexpanded parameter pack 'Types'}}
222a669c534cf414339060868d70d2348fea9ce6c7dDouglas Gregor    }
223a669c534cf414339060868d70d2348fea9ce6c7dDouglas Gregor  }
224e186269a8a41dbff1ebea2c251048892979d1078Douglas Gregor};
225e186269a8a41dbff1ebea2c251048892979d1078Douglas Gregor
226a669c534cf414339060868d70d2348fea9ce6c7dDouglas Gregor// FIXME: Test for unexpanded parameter packs in each of the statements.
22710ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregorstruct X {
22810ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  void f(int, int);
22910ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  template<typename ...Types>
23010ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  void f(Types...);
23110ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor};
23210ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
23310ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregornamespace std {
23410ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  class type_info;
23510ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor}
23610ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
23710ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregortypedef struct _GUID {
23810ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor     unsigned long  Data1;
23910ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor     unsigned short Data2;
24010ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor     unsigned short Data3;
24110ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor     unsigned char  Data4[ 8 ];
24210ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor} GUID;
24310ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
24410ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregortemplate<typename T, typename ...Types>
24510ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregorvoid test_unexpanded_exprs(Types ...values) {
24610ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  // CXXOperatorCallExpr
24710ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  (void)(values + 0); // expected-error{{expression contains unexpanded parameter pack 'values'}}
24810ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  (void)(0 + values); // expected-error{{expression contains unexpanded parameter pack 'values'}}
24910ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
25010ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  // CXXMemberCallExpr
25110ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  values.f(); // expected-error{{expression contains unexpanded parameter pack 'values'}}
25210ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  X x;
25310ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  x.f(values); // expected-error{{expression contains unexpanded parameter pack 'values'}}
25410ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  x.Types::f(); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
25510ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  x.f<Types>(); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
25610ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
25710ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  // CXXStaticCastExpr
25810ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  (void)static_cast<Types&>(values); // expected-error{{expression contains unexpanded parameter packs 'Types' and 'values'}}
25910ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
26010ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  // CXXDynamicCastExpr
26110ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  (void)dynamic_cast<Types&>(values); // expected-error{{expression contains unexpanded parameter packs 'Types' and 'values'}}
26210ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
26310ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  // CXXReinterpretCastExpr
26410ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  (void)reinterpret_cast<Types&>(values); // expected-error{{expression contains unexpanded parameter packs 'Types' and 'values'}}
26510ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
26610ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  // CXXConstCastExpr
26710ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  (void)const_cast<Types&>(values); // expected-error{{expression contains unexpanded parameter packs 'Types' and 'values'}}
26810ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
26910ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  // CXXTypeidExpr
27010ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  (void)typeid(Types); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
27110ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  (void)typeid(values); // expected-error{{expression contains unexpanded parameter pack 'values'}}
27210ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
27310ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  // CXXUuidofExpr
27410ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  (void)__uuidof(Types); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
27510ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  (void)__uuidof(values); // expected-error{{expression contains unexpanded parameter pack 'values'}}
27610ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
27710ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  // CXXThisExpr is uninteresting
27810ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
27910ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  // CXXThrowExpr
28010ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  throw Types(); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
28110ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  throw values; // expected-error{{expression contains unexpanded parameter pack 'values'}}
28210ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
28310ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  // CXXDefaultArgExpr is uninteresting
28410ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
28510ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  // CXXBindTemporaryExpr is uninteresting
28610ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
28710ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  // CXXConstructExpr is uninteresting
28810ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
28910ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  // CXXFunctionalCastExpr
29010ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  (void)Types(); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
29110ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
29210ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  // CXXTemporaryObjectExpr
29310ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  (void)X(values); // expected-error{{expression contains unexpanded parameter pack 'values'}}
29410ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
29510ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  // CXXScalarValueInitExpr is uninteresting
29610ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
29710ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  // CXXNewExpr
29810ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  (void)new Types; // expected-error{{expression contains unexpanded parameter pack 'Types'}}
29910ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  (void)new X(values); // expected-error{{expression contains unexpanded parameter pack 'values'}}
30010ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  (void)new (values) X(values); // expected-error{{expression contains unexpanded parameter pack 'values'}}
30110ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  (void)new X [values]; // expected-error{{expression contains unexpanded parameter pack 'values'}}
30210ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
30310ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  // CXXDeleteExpr
30410ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  delete values; // expected-error{{expression contains unexpanded parameter pack 'values'}}
30510ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  delete [] values; // expected-error{{expression contains unexpanded parameter pack 'values'}}
30610ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
30710ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  // CXXPseudoDestructorExpr
30810ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  T t;
30910ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  values.~T(); // expected-error{{expression contains unexpanded parameter pack 'values'}}
31010ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  t.~Types(); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
31110ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  t.Types::~T(); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
31210ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
313651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  // Unary TypeTraitExpr
31410ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  __is_pod(Types); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
31510ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
316651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines  // Binary TypeTraitExpr
31710ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  __is_base_of(Types, T); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
31810ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  __is_base_of(T, Types); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
31910ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
32010ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  // UnresolvedLookupExpr
32110ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  test_unexpanded_exprs(values); // expected-error{{expression contains unexpanded parameter pack 'values'}}
32210ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  test_unexpanded_exprs<Types>(); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
32310ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
32410ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  // DependentScopeDeclRefExpr
32510ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  Types::test_unexpanded_exprs(); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
32610ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  T::template test_unexpanded_exprs<Types>(); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
32710ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
32810ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  // CXXUnresolvedConstructExpr
32910ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  Types(5); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
33010ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
33110ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  // CXXDependentScopeMemberExpr
33210ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  values.foo(); // expected-error{{expression contains unexpanded parameter pack 'values'}}
33310ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  t.foo(values); // expected-error{{expression contains unexpanded parameter pack 'values'}}
33410ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
33510ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  // FIXME: There's an evil ambiguity here, because we don't know if
33610ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  // Types refers to the template type parameter pack in scope or a
33710ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  // non-pack member.
33810ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  //  t.Types::foo();
33910ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
34010ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  t.template foo<Types>(); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
34110ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
34210ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  // UnresolvedMemberExpr
34310ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  x.f<Types>(); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
34410ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  x.f(values); // expected-error{{expression contains unexpanded parameter pack 'values'}}
34510ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
34610ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  // CXXNoexceptExpr
34710ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  noexcept(values); // expected-error{{expression contains unexpanded parameter pack 'values'}}
34810ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
34910ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  // PackExpansionExpr is uninteresting
35010ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  // SizeOfPackExpr is uninteresting
35110ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor
35210ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor  // FIXME: Objective-C expressions will need to go elsewhere
353ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith
354ad762fcdc16b9e4705b12b09d92b8c026212b906Richard Smith  for (auto t : values) { } // expected-error{{expression contains unexpanded parameter pack 'values'}}
355419563768ef4929a622d7c2b066856e82901bb91Richard Smith
356419563768ef4929a622d7c2b066856e82901bb91Richard Smith  switch (values) { } // expected-error{{expression contains unexpanded parameter pack 'values'}}
357419563768ef4929a622d7c2b066856e82901bb91Richard Smith
358419563768ef4929a622d7c2b066856e82901bb91Richard Smith  do { } while (values); // expected-error{{expression contains unexpanded parameter pack 'values'}}
359419563768ef4929a622d7c2b066856e82901bb91Richard Smith
360419563768ef4929a622d7c2b066856e82901bb91Richard Smithtest:
361419563768ef4929a622d7c2b066856e82901bb91Richard Smith  goto *values; // expected-error{{expression contains unexpanded parameter pack 'values'}}
362419563768ef4929a622d7c2b066856e82901bb91Richard Smith
363419563768ef4929a622d7c2b066856e82901bb91Richard Smith  void f(int arg = values); // expected-error{{default argument contains unexpanded parameter pack 'values'}}
36410ffc00e2177f042808f507c8dd50b744ed6f738Douglas Gregor}
365a669c534cf414339060868d70d2348fea9ce6c7dDouglas Gregor
366925910d488051cbd4e38f350c1e9d69c473f09a0Douglas Gregor// Test unexpanded parameter packs in partial specializations.
367925910d488051cbd4e38f350c1e9d69c473f09a0Douglas Gregortemplate<typename ...Types>
368925910d488051cbd4e38f350c1e9d69c473f09a0Douglas Gregorstruct TestUnexpandedDecls<int, Types>; // expected-error{{partial specialization contains unexpanded parameter pack 'Types'}}
369a669c534cf414339060868d70d2348fea9ce6c7dDouglas Gregor
370e186269a8a41dbff1ebea2c251048892979d1078Douglas Gregor// Test for diagnostics in the presence of multiple unexpanded
371e186269a8a41dbff1ebea2c251048892979d1078Douglas Gregor// parameter packs.
3729ef75899bae6dd9a4be1252ae9cadcb619c170ffDouglas Gregortemplate<typename T, typename U> struct pair;
3739ef75899bae6dd9a4be1252ae9cadcb619c170ffDouglas Gregor
3749ef75899bae6dd9a4be1252ae9cadcb619c170ffDouglas Gregortemplate<typename ...OuterTypes>
3759ef75899bae6dd9a4be1252ae9cadcb619c170ffDouglas Gregorstruct MemberTemplatePPNames {
3769ef75899bae6dd9a4be1252ae9cadcb619c170ffDouglas Gregor  template<typename ...InnerTypes>
3779ef75899bae6dd9a4be1252ae9cadcb619c170ffDouglas Gregor  struct Inner {
3789ef75899bae6dd9a4be1252ae9cadcb619c170ffDouglas Gregor    typedef pair<OuterTypes, InnerTypes>* types; // expected-error{{declaration type contains unexpanded parameter packs 'OuterTypes' and 'InnerTypes'}}
3799ef75899bae6dd9a4be1252ae9cadcb619c170ffDouglas Gregor
3809ef75899bae6dd9a4be1252ae9cadcb619c170ffDouglas Gregor    template<typename ...VeryInnerTypes>
3819ef75899bae6dd9a4be1252ae9cadcb619c170ffDouglas Gregor    struct VeryInner {
3829ef75899bae6dd9a4be1252ae9cadcb619c170ffDouglas Gregor      typedef pair<pair<VeryInnerTypes, OuterTypes>, pair<InnerTypes, OuterTypes> > types; // expected-error{{declaration type contains unexpanded parameter packs 'VeryInnerTypes', 'OuterTypes', ...}}
3839ef75899bae6dd9a4be1252ae9cadcb619c170ffDouglas Gregor    };
3849ef75899bae6dd9a4be1252ae9cadcb619c170ffDouglas Gregor  };
3859ef75899bae6dd9a4be1252ae9cadcb619c170ffDouglas Gregor};
386e186269a8a41dbff1ebea2c251048892979d1078Douglas Gregor
38712c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor// Example from working paper
38812c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregornamespace WorkingPaperExample {
38912c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor  template<typename...> struct Tuple {};
39012c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor  template<typename T1, typename T2> struct Pair {};
39112c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor
39212c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor  template<class ... Args1> struct zip {
39312c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor    template<class ... Args2> struct with {
39412c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor      typedef Tuple<Pair<Args1, Args2> ... > type; // expected-error{{pack expansion contains parameter packs 'Args1' and 'Args2' that have different lengths (1 vs. 2)}}
39512c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor    };
39612c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor  };
39712c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor
39812c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor  typedef zip<short, int>::with<unsigned short, unsigned>::type T1; // T1 is Tuple<Pair<short, unsigned short>, Pair<int, unsigned>>
39912c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor  typedef Tuple<Pair<short, unsigned short>, Pair<int, unsigned>> T1;
40012c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor
40112c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor  typedef zip<short>::with<unsigned short, unsigned>::type T2; // expected-note{{in instantiation of template class}}
40212c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor
40312c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor  template<class ... Args> void f(Args...);
40412c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor  template<class ... Args> void h(Args...);
40512c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor
40612c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor  template<class ... Args>
40712c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor  void g(Args ... args) {
40812c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor    f(const_cast<const Args*>(&args)...); // OK: "Args" and "args" are expanded within f
40912c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor    f(5 ...); // expected-error{{pack expansion does not contain any unexpanded parameter packs}}
41012c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor    f(args); // expected-error{{expression contains unexpanded parameter pack 'args'}}
41112c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor    f(h(args ...) + args ...);
41212c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor  }
41312c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor}
41498a75581e155a7dac853a69b0151960f8e2aacbdNick Lewycky
41598a75581e155a7dac853a69b0151960f8e2aacbdNick Lewyckynamespace PR16303 {
41698a75581e155a7dac853a69b0151960f8e2aacbdNick Lewycky  template<int> struct A { A(int); };
41798a75581e155a7dac853a69b0151960f8e2aacbdNick Lewycky  template<int...N> struct B {
41898a75581e155a7dac853a69b0151960f8e2aacbdNick Lewycky    template<int...M> struct C : A<N>... {
41998a75581e155a7dac853a69b0151960f8e2aacbdNick Lewycky      C() : A<N>(M)... {} // expected-error{{pack expansion contains parameter packs 'N' and 'M' that have different lengths (2 vs. 3)}} expected-error{{pack expansion contains parameter packs 'N' and 'M' that have different lengths (4 vs. 3)}}
42098a75581e155a7dac853a69b0151960f8e2aacbdNick Lewycky    };
42198a75581e155a7dac853a69b0151960f8e2aacbdNick Lewycky  };
42298a75581e155a7dac853a69b0151960f8e2aacbdNick Lewycky  B<1,2>::C<4,5,6> c1; // expected-note{{in instantiation of}}
42398a75581e155a7dac853a69b0151960f8e2aacbdNick Lewycky  B<1,2,3,4>::C<4,5,6> c2; // expected-note{{in instantiation of}}
42498a75581e155a7dac853a69b0151960f8e2aacbdNick Lewycky}
425