54 lines · cpp
1// RUN: %clang_cc1 -std=c++2c -verify=cxx26 -fsyntax-only -Wpre-c++26-compat %s2// RUN: %clang_cc1 -std=c++11 -verify=cxx11 -fsyntax-only -Wc++26-extensions %s3 4template <typename... T>5void 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 23template <typename... T>24void 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 30template <typename... T>31void h(T... param[1]);32 33template <class T>34struct S {35 using type = T;36};37 38template <typename... T>39void 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 42template <typename... T>43void 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 47void 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}54