84 lines · cpp
1// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcxx-exceptions -fexceptions -verify %s2 3// When it is part of a parameter-declaration-clause, the parameter4// pack is a function parameter pack.5template<typename ...Types>6void f0(Types ...args);7 8template<typename ...Types>9void f1(const Types &...args);10 11// [ Note: Otherwise, the parameter-declaration is part of a12// template-parameter-list and the parameter pack is a template13// parameter pack; see 14.1. -- end note ]14template<int ...N>15struct X0 { };16 17template<typename ...Types>18struct X1 {19 template<Types ...Values> struct Inner;20};21 22// A declarator-id or abstract-declarator containing an ellipsis shall23// only be used in a parameter-declaration.24int (...f2)(int); // expected-error{{only function and template parameters can be parameter packs}}25 26void f3() {27 int ...x; // expected-error{{only function and template parameters can be parameter packs}}28 if (int ...y = 17) { } // expected-error{{only function and template parameters can be parameter packs}}29 30 for (int ...z = 0; z < 10; ++z) { } // expected-error{{only function and template parameters can be parameter packs}}31 32 try {33 } catch (int ...e) { // expected-error{{only function and template parameters can be parameter packs}}34 }35}36 37template<typename ...Types>38struct X2 {39 Types ...members; // expected-error{{only function and template parameters can be parameter packs}} \40 // expected-error{{data member type contains unexpanded parameter pack}}41};42 43// The type T of the declarator-id of the function parameter pack44// shall contain a template parameter pack; each template parameter45// pack in T is expanded by the function parameter pack.46template<typename T>47void f4(T ...args); // expected-error{{type 'T' of function parameter pack does not contain any unexpanded parameter packs}}48 49void f4i(int ... x); // expected-error{{type 'int' of function parameter pack does not contain any unexpanded parameter packs}}50void f4i0(int ...);51 52namespace array_type {53template<typename T>54void a(T[] ... x); // expected-error{{expected ')'}} expected-note{{to match this '('}}55 56template<typename T>57void b(T[] ...);58 59template<typename T>60void c(T ... []); // expected-error {{type 'T[]' of function parameter pack does not contain any unexpanded parameter packs}}61 62// A function that takes pointers to each type T as arguments, after any decay.63template <typename ...T>64void g(T...[]);65 66template<typename T>67void d(T ... x[]); // expected-error{{type 'T[]' of function parameter pack does not contain any unexpanded parameter packs}}68 69void ai(int[] ... x); // expected-error{{expected ')'}} expected-note{{to match this '('}}70void bi(int[] ...);71void ci(int ... []); // expected-error{{type 'int[]' of function parameter pack does not contain any unexpanded parameter packs}}72void di(int ... x[]); // expected-error{{type 'int[]' of function parameter pack does not contain any unexpanded parameter packs}}73}74 75void f5a(auto fp(int)->unk ...) {} // expected-error{{unknown type name 'unk'}}76void f5b(auto fp(int)->auto ...) {} // expected-error{{'auto' not allowed in function return type}}77void f5c(auto fp()->...) {} // expected-error{{expected a type}}78 79// FIXME: Expand for function and member pointer types.80 81 82 83 84