File: cxx2c-pack-indexing-ext-diags.cpp

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.8-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,388 kB
  • sloc: cpp: 7,438,767; ansic: 1,393,871; asm: 1,012,926; python: 241,728; f90: 86,635; objc: 75,411; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (53 lines) | stat: -rw-r--r-- 2,403 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// RUN: %clang_cc1 -std=c++2c -verify=cxx26 -fsyntax-only -Wpre-c++26-compat %s
// RUN: %clang_cc1 -std=c++11 -verify=cxx11 -fsyntax-only -Wc++26-extensions %s

template <typename... T>
void f(T... t) {
    // cxx26-warning@+2 {{pack indexing is incompatible with C++ standards before C++2c}}
    // cxx11-warning@+1 {{pack indexing is a C++2c extension}}
    using a = T...[0];

    // cxx26-warning@+2 {{pack indexing is incompatible with C++ standards before C++2c}}
    // cxx11-warning@+1 {{pack indexing is a C++2c extension}}
    using b = typename T...[0]::a;

    // cxx26-warning@+2 2{{pack indexing is incompatible with C++ standards before C++2c}}
    // cxx11-warning@+1 2{{pack indexing is a C++2c extension}}
    t...[0].~T...[0]();

    // cxx26-warning@+2 {{pack indexing is incompatible with C++ standards before C++2c}}
    // cxx11-warning@+1 {{pack indexing is a C++2c extension}}
    T...[0] c;
}

template <typename... T>
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}} \
                  // cxx11-warning {{pack indexing is a C++2c extension}} \
                  // cxx11-note {{candidate function template not viable}} \
                  // cxx26-warning {{pack indexing is incompatible with C++ standards before C++2c}} \
                  // cxx26-note {{candidate function template not viable}}

template <typename... T>
void h(T... param[1]);

template <class T>
struct S {
  using type = T;
};

template <typename... T>
void h(typename T... [1]::type); // cxx11-warning {{pack indexing is a C++2c extension}} \
                                 // cxx26-warning {{pack indexing is incompatible with C++ standards before C++2c}}

template <typename... T>
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}} \
                  // cxx11-warning {{pack indexing is a C++2c extension}} \
                  // cxx26-warning {{pack indexing is incompatible with C++ standards before C++2c}}

void call() {
  g<int, double>(nullptr, nullptr); // cxx26-error {{no matching function for call to 'g'}} \
                                    // cxx11-error {{no matching function for call to 'g'}}
  h<int, double>(nullptr, nullptr);
  h<S<int>, S<const char *>>("hello");
  x<int*>(nullptr);
}