p5.cpp revision 399ad970a25efcbfa7111e17f48285a70fba2731
1fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow// RUN: %clang_cc1 -std=c++0x -fblocks -fsyntax-only -verify %s 2fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow 3fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow 4fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow// An appearance of a name of a parameter pack that is not expanded is 5fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow// ill-formed. 6fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow 7fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clowtemplate<typename T, typename U> struct pair; 8fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow 9fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow// Test for unexpanded parameter packs in each of the type nodes. 10fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clowtemplate<typename T, int N, typename ... Types> 11fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clowstruct TestPPName 12fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow : public Types, public T // expected-error{{base type contains unexpanded parameter pack 'Types'}} 13fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow{ 14fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow // BuiltinType is uninteresting 15fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow // FIXME: ComplexType is uninteresting? 16fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow // PointerType 17fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow typedef Types *types_pointer; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} 18fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow 19fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow // BlockPointerType 20fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow typedef Types (^block_pointer_1)(int); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} 21fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow typedef int (^block_pointer_2)(Types); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} 22fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow 23fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow // LValueReferenceType 24fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow typedef Types &lvalue_ref; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} 25fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow 26fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow // RValueReferenceType 27fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow typedef Types &&rvalue_ref; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} 28fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow 29fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow // MemberPointerType 30fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow typedef Types TestPPName::* member_pointer_1; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} 31fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow typedef int Types::*member_pointer_2; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} 32fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow 33fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow // ConstantArrayType 34fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow typedef Types constant_array[17]; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} 35fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow 36fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow // IncompleteArrayType 37fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow typedef Types incomplete_array[]; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} 38fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow 39fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow // VariableArrayType 40fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow void f(int i) { 41fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow Types variable_array[i]; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} 42fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow } 43fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow 44fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow // DependentSizedArrayType 45fd7481e96de307dd0e43c96d5b025b7c779f72d7Marshall Clow typedef Types dependent_sized_array[N]; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} 46 47 // DependentSizedExtVectorType 48 typedef Types dependent_sized_ext_vector __attribute__((ext_vector_type(N))); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} 49 50 // VectorType is uninteresting 51 52 // ExtVectorType 53 typedef Types ext_vector __attribute__((ext_vector_type(4))); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} 54 55 // FunctionProtoType 56 typedef Types (function_type_1)(int); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} 57 typedef int (function_type_2)(Types); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} 58 59 // FunctionNoProtoType is uninteresting 60 // UnresolvedUsingType is uninteresting 61 // ParenType is uninteresting 62 // TypedefType is uninteresting 63 64 // TypeOfExprType 65 typedef __typeof__((static_cast<Types>(0))) typeof_expr; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} 66 67 // TypeOfType 68 typedef __typeof__(Types) typeof_type; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} 69 70 // DecltypeType 71 typedef decltype((static_cast<Types>(0))) typeof_expr; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} 72 73 // RecordType is uninteresting 74 // EnumType is uninteresting 75 // ElaboratedType is uninteresting 76 77 // TemplateTypeParmType 78 typedef Types template_type_parm; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} 79 80 // SubstTemplateTypeParmType is uninteresting 81 82 // TemplateSpecializationType 83 typedef pair<Types, int> template_specialization; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} 84 85 // InjectedClassName is uninteresting. 86 87 // DependentNameType 88 typedef typename Types::type dependent_name; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} 89 90 // DependentTemplateSpecializationType 91 typedef typename Types::template apply<int> dependent_name_1; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} 92 typedef typename T::template apply<Types> dependent_name_2; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} 93 94 // ObjCObjectType is uninteresting 95 // ObjCInterfaceType is uninteresting 96 // ObjCObjectPointerType is uninteresting 97}; 98 99// FIXME: Test for unexpanded parameter packs in each of the expression nodes. 100 101template<typename ... Types> 102void TestPPNameFunc(int i) { 103 f(static_cast<Types>(i)); // expected-error{{expression contains unexpanded parameter pack 'Types'}} 104} 105 106// FIXME: Test for unexpanded parameter packs in declarations. 107template<typename... Types> 108struct TestUnexpandedDecls { 109 void member_function(Types); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} 110 void member_function () throw(Types); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} 111 Types data_member; // expected-error{{data member type contains unexpanded parameter pack 'Types'}} 112 static Types static_data_member; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} 113 unsigned bit_field : static_cast<Types>(0); // expected-error{{bit-field size contains unexpanded parameter pack 'Types'}} 114 static_assert(static_cast<Types>(0), "Boom"); // expected-error{{static assertion contains unexpanded parameter pack 'Types'}} 115}; 116 117// Test for diagnostics in the presence of multiple unexpanded 118// parameter packs. 119template<typename T, typename U> struct pair; 120 121template<typename ...OuterTypes> 122struct MemberTemplatePPNames { 123 template<typename ...InnerTypes> 124 struct Inner { 125 typedef pair<OuterTypes, InnerTypes>* types; // expected-error{{declaration type contains unexpanded parameter packs 'OuterTypes' and 'InnerTypes'}} 126 127 template<typename ...VeryInnerTypes> 128 struct VeryInner { 129 typedef pair<pair<VeryInnerTypes, OuterTypes>, pair<InnerTypes, OuterTypes> > types; // expected-error{{declaration type contains unexpanded parameter packs 'VeryInnerTypes', 'OuterTypes', ...}} 130 }; 131 }; 132}; 133 134