Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/comma3.C

raw
1 // PR c++/91338 - P1161R3: Deprecate a[b,c].
2 // { dg-do compile { target c++11 } }
3 // { dg-options "-Wcomma-subscript" }
4
5 struct S {
6 int operator,(int) { return 42; }
7 };
8
9 void
10 fn (int *a, int b, int c)
11 {
12 a[b,c]; // { dg-warning "top-level comma expression in array subscript is deprecated" "" { target c++20_down } }
13 // { dg-warning "top-level comma expression in array subscript changed meaning in" "" { target c++23 } .-1 }
14 a[(b,c)];
15
16 a[(void) b, c]; // { dg-warning "top-level comma expression in array subscript is deprecated" "" { target c++20_down } }
17 // { dg-warning "top-level comma expression in array subscript changed meaning in" "" { target c++23 } .-1 }
18 a[((void) b, c)];
19
20 a[(void) b, (void) c, (void) b, b]; // { dg-warning "top-level comma expression in array subscript is deprecated" "" { target c++20_down } }
21 // { dg-warning "top-level comma expression in array subscript changed meaning in" "" { target c++23 } .-1 }
22 a[((void) b, (void) c, (void) b, b)];
23
24 a[S(), 10]; // { dg-warning "top-level comma expression in array subscript is deprecated" "" { target c++20_down } }
25 // { dg-warning "top-level comma expression in array subscript changed meaning in" "" { target c++23 } .-1 }
26 a[(S(), 10)];
27
28 a[int{(1,2)}];
29 a[int{(1,2)}, int{}]; // { dg-warning "top-level comma expression in array subscript is deprecated" "" { target c++20_down } }
30 // { dg-warning "top-level comma expression in array subscript changed meaning in" "" { target c++23 } .-1 }
31 a[(int{(1,2)}, int{})];
32 }