1762bb9d0ad20320b9f97a841dce57ba5e8e48b07Richard Smith// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcxx-exceptions -fexceptions -verify %s
2a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregor
3a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregor// When it is part of a parameter-declaration-clause, the parameter
4a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregor// pack is a function parameter pack.
5a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregortemplate<typename ...Types>
6603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregorvoid f0(Types ...args);
7a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregor
8a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregortemplate<typename ...Types>
9603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregorvoid f1(const Types &...args);
10a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregor
11a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregor// [ Note: Otherwise, the parameter-declaration is part of a
12a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregor// template-parameter-list and the parameter pack is a template
13a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregor// parameter pack; see 14.1. -- end note ]
1410738d36b150aa65206890c1c845cdba076e4200Douglas Gregortemplate<int ...N>
15a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregorstruct X0 { };
16a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregor
17a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregortemplate<typename ...Types>
18a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregorstruct X1 {
1910738d36b150aa65206890c1c845cdba076e4200Douglas Gregor  template<Types ...Values> struct Inner;
20a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregor};
21a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregor
22a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregor// A declarator-id or abstract-declarator containing an ellipsis shall
23a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregor// only be used in a parameter-declaration.
24a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregorint (...f2)(int); // expected-error{{only function and template parameters can be parameter packs}}
25a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregor
26a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregorvoid f3() {
27a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregor  int ...x; // expected-error{{only function and template parameters can be parameter packs}}
28a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregor  if (int ...y = 17) { }  // expected-error{{only function and template parameters can be parameter packs}}
29a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregor
30a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregor  for (int ...z = 0; z < 10; ++z) { }  // expected-error{{only function and template parameters can be parameter packs}}
31a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregor
32a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregor  try {
33a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregor  } catch (int ...e) { // expected-error{{only function and template parameters can be parameter packs}}
34a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregor  }
35a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregor}
36a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregor
37a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregortemplate<typename ...Types>
38a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregorstruct X2 {
39a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregor  Types ...members; // expected-error{{only function and template parameters can be parameter packs}} \
40a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregor                    // expected-error{{data member type contains unexpanded parameter pack}}
41a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregor};
42a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregor
43a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregor// The type T of the declarator-id of the function parameter pack
44a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregor// shall contain a template parameter pack; each template parameter
45a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregor// pack in T is expanded by the function parameter pack.
46a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregortemplate<typename T>
47a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregorvoid f4(T ...args); // expected-error{{type 'T' of function parameter pack does not contain any unexpanded parameter packs}}
48a8bc8c9e9ba5bffebde00340786fe8542469c435Douglas Gregor
49176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hinesvoid f4i(int ... x); // expected-error{{type 'int' of function parameter pack does not contain any unexpanded parameter packs}}
50176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hinesvoid f4i0(int ...);
51176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines
52176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hinesnamespace array_type {
53176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hinestemplate<typename T>
54176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hinesvoid a(T[] ... x); // expected-error{{expected ')'}} expected-note{{to match this '('}}
55176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines
56176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hinestemplate<typename T>
57176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hinesvoid b(T[] ...);
58176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines
59176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hinestemplate<typename T>
60176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hinesvoid c(T ... []); // expected-error{{type 'T []' of function parameter pack does not contain any unexpanded parameter packs}}
61176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines
62176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hinestemplate<typename T>
63176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hinesvoid d(T ... x[]); // expected-error{{type 'T []' of function parameter pack does not contain any unexpanded parameter packs}}
64176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines
65176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hinesvoid ai(int[] ... x); // expected-error{{expected ')'}} expected-note{{to match this '('}}
66176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hinesvoid bi(int[] ...);
67176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hinesvoid ci(int ... []); // expected-error{{type 'int []' of function parameter pack does not contain any unexpanded parameter packs}}
68176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hinesvoid di(int ... x[]); // expected-error{{type 'int []' of function parameter pack does not contain any unexpanded parameter packs}}
69176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines}
70176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines
710e2c34f92f00628d48968dfea096d36381f494cbStephen Hinesvoid f5a(auto fp(int)->unk ...) {} // expected-error{{unknown type name 'unk'}}
720e2c34f92f00628d48968dfea096d36381f494cbStephen Hinesvoid f5b(auto fp(int)->auto ...) {} // expected-error{{'auto' not allowed in function return type}}
730e2c34f92f00628d48968dfea096d36381f494cbStephen Hinesvoid f5c(auto fp()->...) {} // expected-error{{expected a type}}
740e2c34f92f00628d48968dfea096d36381f494cbStephen Hines
75176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines// FIXME: Expand for function and member pointer types.
76176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines
77176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines
78176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines
79176edba5311f6eff0cad2631449885ddf4fbc9eaStephen Hines
80