2011-10-14 06:29:44 +08:00
|
|
|
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcxx-exceptions -fexceptions -verify %s
|
2010-12-24 06:44:42 +08:00
|
|
|
|
|
|
|
// When it is part of a parameter-declaration-clause, the parameter
|
|
|
|
// pack is a function parameter pack.
|
|
|
|
template<typename ...Types>
|
2011-01-06 07:12:31 +08:00
|
|
|
void f0(Types ...args);
|
2010-12-24 06:44:42 +08:00
|
|
|
|
|
|
|
template<typename ...Types>
|
2011-01-06 07:12:31 +08:00
|
|
|
void f1(const Types &...args);
|
2010-12-24 06:44:42 +08:00
|
|
|
|
|
|
|
// [ Note: Otherwise, the parameter-declaration is part of a
|
|
|
|
// template-parameter-list and the parameter pack is a template
|
|
|
|
// parameter pack; see 14.1. -- end note ]
|
2010-12-24 07:51:58 +08:00
|
|
|
template<int ...N>
|
2010-12-24 06:44:42 +08:00
|
|
|
struct X0 { };
|
|
|
|
|
|
|
|
template<typename ...Types>
|
|
|
|
struct X1 {
|
2010-12-24 07:51:58 +08:00
|
|
|
template<Types ...Values> struct Inner;
|
2010-12-24 06:44:42 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// A declarator-id or abstract-declarator containing an ellipsis shall
|
|
|
|
// only be used in a parameter-declaration.
|
|
|
|
int (...f2)(int); // expected-error{{only function and template parameters can be parameter packs}}
|
|
|
|
|
|
|
|
void f3() {
|
|
|
|
int ...x; // expected-error{{only function and template parameters can be parameter packs}}
|
|
|
|
if (int ...y = 17) { } // expected-error{{only function and template parameters can be parameter packs}}
|
|
|
|
|
|
|
|
for (int ...z = 0; z < 10; ++z) { } // expected-error{{only function and template parameters can be parameter packs}}
|
|
|
|
|
|
|
|
try {
|
|
|
|
} catch (int ...e) { // expected-error{{only function and template parameters can be parameter packs}}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename ...Types>
|
|
|
|
struct X2 {
|
|
|
|
Types ...members; // expected-error{{only function and template parameters can be parameter packs}} \
|
|
|
|
// expected-error{{data member type contains unexpanded parameter pack}}
|
|
|
|
};
|
|
|
|
|
|
|
|
// The type T of the declarator-id of the function parameter pack
|
|
|
|
// shall contain a template parameter pack; each template parameter
|
|
|
|
// pack in T is expanded by the function parameter pack.
|
|
|
|
template<typename T>
|
|
|
|
void f4(T ...args); // expected-error{{type 'T' of function parameter pack does not contain any unexpanded parameter packs}}
|
|
|
|
|