[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Parser / cxx2c-pack-indexing.cpp
blobc279bdd7af8c44147fd82d710200880d33713e44
1 // RUN: %clang_cc1 -std=c++2c -verify -fsyntax-only %s
3 template<typename... T>
4 struct S {
5 T...1; // expected-error{{expected member name or ';' after declaration specifiers}}
6 T...[; // expected-error{{expected expression}} \
7 // expected-error{{expected ']'}} \
8 // expected-note {{to match this '['}} \
9 // expected-warning{{declaration does not declare anything}}
11 T...[1; // expected-error{{expected ']'}} \
12 // expected-note {{to match this '['}} \
13 // expected-warning{{declaration does not declare anything}}
15 T...[]; // expected-error{{expected expression}} \
16 // expected-warning{{declaration does not declare anything}}
18 void f(auto... v) {
19 decltype(v...[1]) a = v...[1];
20 decltype(v...[1]) b = v...[]; // expected-error{{expected expression}}
22 decltype(v...[1]) c = v...[ ; // expected-error{{expected expression}}\
23 // expected-error{{expected ']'}} \
24 // expected-note {{to match this '['}}
29 template <typename...>
30 struct typelist{};
32 template <typename... T>
33 requires requires(T...[0]) { {T...[0](0)}; }
34 struct SS : T...[1] {
35 [[maybe_unused]] T...[1] base = {};
36 using foo = T...[1];
37 SS()
38 : T...[1]()
40 typelist<T...[0]> a;
41 const T...[0] f(T...[0] && p) noexcept((T...[0])0) {
42 T...[0] (*test)(const volatile T...[0]**);
43 thread_local T...[0] d;
44 [[maybe_unused]] T...[0] a = p;
45 auto ptr = new T...[0](0);
46 (*ptr).~T...[0]();
47 return T...[0](0);
48 typename T...[1]::foo b = 0;
49 T...[1]::i = 0;
50 return (T...[0])(a);
51 new T...[0];
52 [[maybe_unused]] auto l = []<T...[0]>(T...[0][1]) -> T...[0]{return{};};
53 [[maybe_unused]] auto _ = l.template operator()<T...[0]{}>({0});
55 operator T...[0]() const{}
58 struct base {
59 using foo = int;
60 static inline int i = 42;
63 int main() {
64 SS<int, base>().f(0);
68 namespace GH11460 {
69 template <typename... T>
70 requires( ); // expected-error {{expected expression}}
71 struct SS {
72 void f( ) {
73 (*p).~T...[](); // expected-error {{use of undeclared identifier 'p'}}