p5.cpp revision 61c4d28e36cd3f1be392cb77f07436d1fa6b0f9f
1cff163e3cc78277496b30fa40070b46abdc290dbDouglas Gregor// RUN: %clang_cc1 -std=c++0x -fblocks -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.
163a31040f16604849b3b1dc36015056c81bae68ad1Douglas Gregor// FIXME: Attributes?
16456c04588ef3cfa1bbc968fd68de2480a4e66971dDouglas Gregortemplate<typename T, typename... Types>
16556c04588ef3cfa1bbc968fd68de2480a4e66971dDouglas Gregorstruct TestUnexpandedDecls : T{
166e186269a8a41dbff1ebea2c251048892979d1078Douglas Gregor  void member_function(Types);  // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
167e186269a8a41dbff1ebea2c251048892979d1078Douglas Gregor  void member_function () throw(Types); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
16856c04588ef3cfa1bbc968fd68de2480a4e66971dDouglas Gregor  operator Types() const; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
169e186269a8a41dbff1ebea2c251048892979d1078Douglas Gregor  Types data_member;  // expected-error{{data member type contains unexpanded parameter pack 'Types'}}
170e186269a8a41dbff1ebea2c251048892979d1078Douglas Gregor  static Types static_data_member; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
171e186269a8a41dbff1ebea2c251048892979d1078Douglas Gregor  unsigned bit_field : static_cast<Types>(0);  // expected-error{{bit-field size contains unexpanded parameter pack 'Types'}}
172399ad970a25efcbfa7111e17f48285a70fba2731Douglas Gregor  static_assert(static_cast<Types>(0), "Boom"); // expected-error{{static assertion contains unexpanded parameter pack 'Types'}}
1730c9e4799fd78d350a037498b2c797f2b2558791cDouglas Gregor
1740c9e4799fd78d350a037498b2c797f2b2558791cDouglas Gregor  enum E0 : Types {  // expected-error{{fixed underlying type contains unexpanded parameter pack 'Types'}}
1750c9e4799fd78d350a037498b2c797f2b2558791cDouglas Gregor    EnumValue = static_cast<Types>(0) // expected-error{{enumerator value contains unexpanded parameter pack 'Types'}}
1760c9e4799fd78d350a037498b2c797f2b2558791cDouglas Gregor  };
17756c04588ef3cfa1bbc968fd68de2480a4e66971dDouglas Gregor
17856c04588ef3cfa1bbc968fd68de2480a4e66971dDouglas Gregor  using typename Types::type; // expected-error{{using declaration contains unexpanded parameter pack 'Types'}}
17956c04588ef3cfa1bbc968fd68de2480a4e66971dDouglas Gregor  using Types::value; // expected-error{{using declaration contains unexpanded parameter pack 'Types'}}
18056c04588ef3cfa1bbc968fd68de2480a4e66971dDouglas Gregor  using T::operator Types; // expected-error{{using declaration contains unexpanded parameter pack 'Types'}}
1816ccab97c17c17f38eb92c7fe02c766508875bd97Douglas Gregor
1826ccab97c17c17f38eb92c7fe02c766508875bd97Douglas Gregor  friend class Types::foo; // expected-error{{friend declaration contains unexpanded parameter pack 'Types'}}
1836ccab97c17c17f38eb92c7fe02c766508875bd97Douglas Gregor  friend void friend_func(Types); // expected-error{{friend declaration contains unexpanded parameter pack 'Types'}}
1846ccab97c17c17f38eb92c7fe02c766508875bd97Douglas Gregor  friend void Types::other_friend_func(int); // expected-error{{friend declaration contains unexpanded parameter pack 'Types'}}
185a31040f16604849b3b1dc36015056c81bae68ad1Douglas Gregor
186a31040f16604849b3b1dc36015056c81bae68ad1Douglas Gregor  void test_initializers() {
187a31040f16604849b3b1dc36015056c81bae68ad1Douglas Gregor    T copy_init = static_cast<Types>(0); // expected-error{{initializer contains unexpanded parameter pack 'Types'}}
188a31040f16604849b3b1dc36015056c81bae68ad1Douglas Gregor    T direct_init(0, static_cast<Types>(0)); // expected-error{{expression contains unexpanded parameter pack 'Types'}}
189a31040f16604849b3b1dc36015056c81bae68ad1Douglas Gregor    T list_init = { static_cast<Types>(0) }; // expected-error{{initializer contains unexpanded parameter pack 'Types'}}
190a31040f16604849b3b1dc36015056c81bae68ad1Douglas Gregor  }
1916f52675ec400a0ee89ec6214c4845b8ee274304aDouglas Gregor
1926f52675ec400a0ee89ec6214c4845b8ee274304aDouglas Gregor  void default_function_args(T = static_cast<Types>(0)); // expected-error{{default argument contains unexpanded parameter pack 'Types'}}
1936f52675ec400a0ee89ec6214c4845b8ee274304aDouglas Gregor
1946f52675ec400a0ee89ec6214c4845b8ee274304aDouglas Gregor  template<typename = Types*> // expected-error{{default argument contains unexpanded parameter pack 'Types'}}
1956f52675ec400a0ee89ec6214c4845b8ee274304aDouglas Gregor    struct default_template_args_1;
1966f52675ec400a0ee89ec6214c4845b8ee274304aDouglas Gregor  template<int = static_cast<Types>(0)> // expected-error{{default argument contains unexpanded parameter pack 'Types'}}
1976f52675ec400a0ee89ec6214c4845b8ee274304aDouglas Gregor    struct default_template_args_2;
1986f52675ec400a0ee89ec6214c4845b8ee274304aDouglas Gregor  template<template<typename> class = Types::template apply> // expected-error{{default argument contains unexpanded parameter pack 'Types'}}
1996f52675ec400a0ee89ec6214c4845b8ee274304aDouglas Gregor    struct default_template_args_3;
200781def075d4a486a5b367c6730fe77cb1f721ac1Douglas Gregor
201781def075d4a486a5b367c6730fe77cb1f721ac1Douglas Gregor  template<Types value> // expected-error{{non-type template parameter type contains unexpanded parameter pack 'Types'}}
202781def075d4a486a5b367c6730fe77cb1f721ac1Douglas Gregor  struct non_type_template_param_type;
203a669c534cf414339060868d70d2348fea9ce6c7dDouglas Gregor
204a669c534cf414339060868d70d2348fea9ce6c7dDouglas Gregor  void decls_in_stmts() {
205a669c534cf414339060868d70d2348fea9ce6c7dDouglas Gregor    Types t; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
206a669c534cf414339060868d70d2348fea9ce6c7dDouglas Gregor    for (Types *t = 0; ; ) { } // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
207a669c534cf414339060868d70d2348fea9ce6c7dDouglas Gregor    for (; Types *t = 0; ) { } // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
208a669c534cf414339060868d70d2348fea9ce6c7dDouglas Gregor    switch(Types *t = 0) { } // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
209a669c534cf414339060868d70d2348fea9ce6c7dDouglas Gregor    while(Types *t = 0) { } // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
210a669c534cf414339060868d70d2348fea9ce6c7dDouglas Gregor    if (Types *t = 0) { } // expected-error{{declaration type contains unexpanded parameter pack 'Types'}}
211a669c534cf414339060868d70d2348fea9ce6c7dDouglas Gregor    try {
212a669c534cf414339060868d70d2348fea9ce6c7dDouglas Gregor    } catch (Types*) { // expected-error{{exception type contains unexpanded parameter pack 'Types'}}
213a669c534cf414339060868d70d2348fea9ce6c7dDouglas Gregor    }
214a669c534cf414339060868d70d2348fea9ce6c7dDouglas Gregor  }
215e186269a8a41dbff1ebea2c251048892979d1078Douglas Gregor};
216e186269a8a41dbff1ebea2c251048892979d1078Douglas Gregor
217a669c534cf414339060868d70d2348fea9ce6c7dDouglas Gregor// FIXME: Test for unexpanded parameter packs in each of the statements.
218a669c534cf414339060868d70d2348fea9ce6c7dDouglas Gregor
219925910d488051cbd4e38f350c1e9d69c473f09a0Douglas Gregor// Test unexpanded parameter packs in partial specializations.
220925910d488051cbd4e38f350c1e9d69c473f09a0Douglas Gregortemplate<typename ...Types>
221925910d488051cbd4e38f350c1e9d69c473f09a0Douglas Gregorstruct TestUnexpandedDecls<int, Types>; // expected-error{{partial specialization contains unexpanded parameter pack 'Types'}}
222a669c534cf414339060868d70d2348fea9ce6c7dDouglas Gregor
223e186269a8a41dbff1ebea2c251048892979d1078Douglas Gregor// Test for diagnostics in the presence of multiple unexpanded
224e186269a8a41dbff1ebea2c251048892979d1078Douglas Gregor// parameter packs.
2259ef75899bae6dd9a4be1252ae9cadcb619c170ffDouglas Gregortemplate<typename T, typename U> struct pair;
2269ef75899bae6dd9a4be1252ae9cadcb619c170ffDouglas Gregor
2279ef75899bae6dd9a4be1252ae9cadcb619c170ffDouglas Gregortemplate<typename ...OuterTypes>
2289ef75899bae6dd9a4be1252ae9cadcb619c170ffDouglas Gregorstruct MemberTemplatePPNames {
2299ef75899bae6dd9a4be1252ae9cadcb619c170ffDouglas Gregor  template<typename ...InnerTypes>
2309ef75899bae6dd9a4be1252ae9cadcb619c170ffDouglas Gregor  struct Inner {
2319ef75899bae6dd9a4be1252ae9cadcb619c170ffDouglas Gregor    typedef pair<OuterTypes, InnerTypes>* types; // expected-error{{declaration type contains unexpanded parameter packs 'OuterTypes' and 'InnerTypes'}}
2329ef75899bae6dd9a4be1252ae9cadcb619c170ffDouglas Gregor
2339ef75899bae6dd9a4be1252ae9cadcb619c170ffDouglas Gregor    template<typename ...VeryInnerTypes>
2349ef75899bae6dd9a4be1252ae9cadcb619c170ffDouglas Gregor    struct VeryInner {
2359ef75899bae6dd9a4be1252ae9cadcb619c170ffDouglas Gregor      typedef pair<pair<VeryInnerTypes, OuterTypes>, pair<InnerTypes, OuterTypes> > types; // expected-error{{declaration type contains unexpanded parameter packs 'VeryInnerTypes', 'OuterTypes', ...}}
2369ef75899bae6dd9a4be1252ae9cadcb619c170ffDouglas Gregor    };
2379ef75899bae6dd9a4be1252ae9cadcb619c170ffDouglas Gregor  };
2389ef75899bae6dd9a4be1252ae9cadcb619c170ffDouglas Gregor};
239e186269a8a41dbff1ebea2c251048892979d1078Douglas Gregor
240