| 1 |
// RUN: %clang_cc1 -std=c++2c -verify=cxx26 -fsyntax-only -Wpre-c++26-compat %s |
| 2 |
// RUN: %clang_cc1 -std=c++11 -verify=cxx11 -fsyntax-only -Wc++26-extensions %s |
| 3 |
|
| 4 |
template <typename... T> |
| 5 |
void f(T... t) { |
| 6 |
// cxx26-warning@+2 {{pack indexing is incompatible with C++ standards before C++2c}} |
| 7 |
// cxx11-warning@+1 {{pack indexing is a C++2c extension}} |
| 8 |
using a = T...[0]; |
| 9 |
|
| 10 |
// cxx26-warning@+2 {{pack indexing is incompatible with C++ standards before C++2c}} |
| 11 |
// cxx11-warning@+1 {{pack indexing is a C++2c extension}} |
| 12 |
using b = typename T...[0]::a; |
| 13 |
|
| 14 |
// cxx26-warning@+2 2{{pack indexing is incompatible with C++ standards before C++2c}} |
| 15 |
// cxx11-warning@+1 2{{pack indexing is a C++2c extension}} |
| 16 |
t...[0].~T...[0](); |
| 17 |
|
| 18 |
// cxx26-warning@+2 {{pack indexing is incompatible with C++ standards before C++2c}} |
| 19 |
// cxx11-warning@+1 {{pack indexing is a C++2c extension}} |
| 20 |
T...[0] c; |
| 21 |
} |
| 22 |
|
| 23 |
template <typename... T> |
| 24 |
void g(T... [1]); // cxx11-warning {{'T...[1]' is no longer a pack expansion but a pack indexing type; add a name to specify a pack expansion}} \ |
| 25 |
// cxx11-warning {{pack indexing is a C++2c extension}} \ |
| 26 |
// cxx11-note {{candidate function template not viable}} \ |
| 27 |
// cxx26-warning {{pack indexing is incompatible with C++ standards before C++2c}} \ |
| 28 |
// cxx26-note {{candidate function template not viable}} |
| 29 |
|
| 30 |
template <typename... T> |
| 31 |
void h(T... param[1]); |
| 32 |
|
| 33 |
template <class T> |
| 34 |
struct S { |
| 35 |
using type = T; |
| 36 |
}; |
| 37 |
|
| 38 |
template <typename... T> |
| 39 |
void h(typename T... [1]::type); // cxx11-warning {{pack indexing is a C++2c extension}} \ |
| 40 |
// cxx26-warning {{pack indexing is incompatible with C++ standards before C++2c}} |
| 41 |
|
| 42 |
template <typename... T> |
| 43 |
void x(T... [0]); // cxx11-warning {{'T...[0]' is no longer a pack expansion but a pack indexing type; add a name to specify a pack expansion}} \ |
| 44 |
// cxx11-warning {{pack indexing is a C++2c extension}} \ |
| 45 |
// cxx26-warning {{pack indexing is incompatible with C++ standards before C++2c}} |
| 46 |
|
| 47 |
void call() { |
| 48 |
g<int, double>(nullptr, nullptr); // cxx26-error {{no matching function for call to 'g'}} \ |
| 49 |
// cxx11-error {{no matching function for call to 'g'}} |
| 50 |
h<int, double>(nullptr, nullptr); |
| 51 |
h<S<int>, S<const char *>>("hello"); |
| 52 |
x<int*>(nullptr); |
| 53 |
} |