blob: 042799c6aba12da311e4c40f973ce1093ccd17b5 (
plain)
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
|
// PR c++/109319
// { dg-do compile { target c++11 } }
// { dg-options "" }
struct A { static int &operator[] (int x) { static int a[2]; return a[x]; } }; // { dg-warning "may be a static member function only with" "" { target c++20_down } }
struct B { int &operator[] (int x) { static int b[2]; return b[x]; } };
int c[2];
template <typename T, typename U, typename V>
int
foo ()
{
A a;
++a[0, 1]; // { dg-warning "top-level comma expression in array subscript changed meaning" "" { target c++23 } }
B b; // { dg-warning "top-level comma expression in array subscript is deprecated" "" { target c++20_only } .-1 }
++b[0, 1]; // { dg-warning "top-level comma expression in array subscript changed meaning" "" { target c++23 } }
// { dg-warning "top-level comma expression in array subscript is deprecated" "" { target c++20_only } .-1 }
++c[0, 1]; // { dg-warning "top-level comma expression in array subscript changed meaning" "" { target c++23 } }
T d; // { dg-warning "top-level comma expression in array subscript is deprecated" "" { target c++20_only } .-1 }
++d[0, 1]; // { dg-warning "top-level comma expression in array subscript changed meaning" "" { target c++23 } }
U e; // { dg-warning "top-level comma expression in array subscript is deprecated" "" { target c++20_only } .-1 }
++e[0, 1]; // { dg-warning "top-level comma expression in array subscript changed meaning" "" { target c++23 } }
extern V f[2]; // { dg-warning "top-level comma expression in array subscript is deprecated" "" { target c++20_only } .-1 }
++f[0, 1]; // { dg-warning "top-level comma expression in array subscript changed meaning" "" { target c++23 } }
return 0; // { dg-warning "top-level comma expression in array subscript is deprecated" "" { target c++20_only } .-1 }
}
int f[2];
int
main ()
{
A a;
++a[0, 1]; // { dg-warning "top-level comma expression in array subscript changed meaning" "" { target c++23 } }
B b; // { dg-warning "top-level comma expression in array subscript is deprecated" "" { target c++20_only } .-1 }
++b[0, 1]; // { dg-warning "top-level comma expression in array subscript changed meaning" "" { target c++23 } }
// { dg-warning "top-level comma expression in array subscript is deprecated" "" { target c++20_only } .-1 }
++c[0, 1]; // { dg-warning "top-level comma expression in array subscript changed meaning" "" { target c++23 } }
foo <A, B, int> (); // { dg-warning "top-level comma expression in array subscript is deprecated" "" { target c++20_only } .-1 }
if (a.operator[] (1) != 3 || b.operator[] (1) != 3 || c[1] != 2 || f[1] != 1)
__builtin_abort ();
}
|