[libc] Deprecate LLVM_ENABLE_PROJECTS in favor of LLVM_ENABLE_RUNTIMES. (#117265)
[llvm-project.git] / clang / test / CXX / dcl.decl / dcl.meaning / dcl.fct / p13.cpp
blobdbb6e60d9b93d7c627283d9b50a448c6f844aecd
1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcxx-exceptions -fexceptions -verify %s
3 // When it is part of a parameter-declaration-clause, the parameter
4 // pack is a function parameter pack.
5 template<typename ...Types>
6 void f0(Types ...args);
8 template<typename ...Types>
9 void f1(const Types &...args);
11 // [ Note: Otherwise, the parameter-declaration is part of a
12 // template-parameter-list and the parameter pack is a template
13 // parameter pack; see 14.1. -- end note ]
14 template<int ...N>
15 struct X0 { };
17 template<typename ...Types>
18 struct X1 {
19 template<Types ...Values> struct Inner;
22 // A declarator-id or abstract-declarator containing an ellipsis shall
23 // only be used in a parameter-declaration.
24 int (...f2)(int); // expected-error{{only function and template parameters can be parameter packs}}
26 void 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}}
30 for (int ...z = 0; z < 10; ++z) { } // expected-error{{only function and template parameters can be parameter packs}}
32 try {
33 } catch (int ...e) { // expected-error{{only function and template parameters can be parameter packs}}
37 template<typename ...Types>
38 struct 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}}
43 // The type T of the declarator-id of the function parameter pack
44 // shall contain a template parameter pack; each template parameter
45 // pack in T is expanded by the function parameter pack.
46 template<typename T>
47 void f4(T ...args); // expected-error{{type 'T' of function parameter pack does not contain any unexpanded parameter packs}}
49 void f4i(int ... x); // expected-error{{type 'int' of function parameter pack does not contain any unexpanded parameter packs}}
50 void f4i0(int ...);
52 namespace array_type {
53 template<typename T>
54 void a(T[] ... x); // expected-error{{expected ')'}} expected-note{{to match this '('}}
56 template<typename T>
57 void b(T[] ...);
59 template<typename T>
60 void c(T ... []); // expected-error {{expected expression}} \
61 // expected-error {{'T' does not refer to the name of a parameter pack}} \
62 // expected-warning {{pack indexing is a C++2c extension}}
64 template<typename T>
65 void d(T ... x[]); // expected-error{{type 'T[]' of function parameter pack does not contain any unexpanded parameter packs}}
67 void ai(int[] ... x); // expected-error{{expected ')'}} expected-note{{to match this '('}}
68 void bi(int[] ...);
69 void ci(int ... []); // expected-error{{type 'int[]' of function parameter pack does not contain any unexpanded parameter packs}}
70 void di(int ... x[]); // expected-error{{type 'int[]' of function parameter pack does not contain any unexpanded parameter packs}}
73 void f5a(auto fp(int)->unk ...) {} // expected-error{{unknown type name 'unk'}}
74 void f5b(auto fp(int)->auto ...) {} // expected-error{{'auto' not allowed in function return type}}
75 void f5c(auto fp()->...) {} // expected-error{{expected a type}}
77 // FIXME: Expand for function and member pointer types.