3 // { dg-options "-std=c++23" }
8 int &operator[] () { return a[0]; }
9 int &operator[] (int x) { return a[x]; }
10 int &operator[] (int x, long y) { return a[x + y * 8]; }
16 operator int () { return 42; };
23 operator int * () { return buf; }
29 V (int x, int y, int z) : a {x, y, z} {};
30 int &operator[] () { return a[0]; } // { dg-message "candidate" }
31 int &operator[] (int x, long y) { return a[x + y * 8]; } // { dg-message "candidate" }
42 auto &a = buf[]; // { dg-error "built-in subscript operator without expression list" }
43 auto &b = buf[1, 2]; // { dg-warning "top-level comma expression in array subscript changed meaning in" }
44 auto &c = s[1, 2, 3]; // { dg-warning "top-level comma expression in array subscript changed meaning in" }
45 auto &d = v[1]; // { dg-error "no match for 'operator\\\[\\\]' in 'v\\\[1\\\]' \\\(operand types are 'V' and 'int'\\\)" }
46 auto &e = v[1, 2, 3]; // { dg-error "no match for call to 'V::operator\\\[\\\] \\\(int, int, int\\\)'" }
47 auto &f = t[42, u]; // { dg-warning "top-level comma expression in array subscript changed meaning in" }
48 auto &g = u[42, t]; // { dg-warning "top-level comma expression in array subscript changed meaning in" }
49 auto &h = buf[42, 2.5]; // { dg-warning "top-level comma expression in array subscript changed meaning in" }
50 // { dg-error "invalid types \[^\n\r]* for array subscript" "" { target *-*-* } .-1 }