aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/comma3.C
blob: daf5359604927755a378f037702dbca5a41911a2 (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
// PR c++/91338 - P1161R3: Deprecate a[b,c].
// { dg-do compile { target c++11 } }
// { dg-options "-Wcomma-subscript" }

struct S {
  int operator,(int) { return 42; }
};

void
fn (int *a, int b, int c)
{
  a[b,c]; // { dg-warning "top-level comma expression in array subscript is deprecated" "" { target c++20_down } }
	  // { dg-warning "top-level comma expression in array subscript changed meaning in" "" { target c++23 } .-1 }
  a[(b,c)];

  a[(void) b, c]; // { dg-warning "top-level comma expression in array subscript is deprecated" "" { target c++20_down } }
		  // { dg-warning "top-level comma expression in array subscript changed meaning in" "" { target c++23 } .-1 }
  a[((void) b, c)];

  a[(void) b, (void) c, (void) b, b]; // { dg-warning "top-level comma expression in array subscript is deprecated" "" { target c++20_down } }
				      // { dg-warning "top-level comma expression in array subscript changed meaning in" "" { target c++23 } .-1 }
  a[((void) b, (void) c, (void) b, b)];

  a[S(), 10]; // { dg-warning "top-level comma expression in array subscript is deprecated" "" { target c++20_down } }
	      // { dg-warning "top-level comma expression in array subscript changed meaning in" "" { target c++23 } .-1 }
  a[(S(), 10)];

  a[int{(1,2)}];
  a[int{(1,2)}, int{}]; // { dg-warning "top-level comma expression in array subscript is deprecated" "" { target c++20_down } }
			// { dg-warning "top-level comma expression in array subscript changed meaning in" "" { target c++23 } .-1 }
  a[(int{(1,2)}, int{})];
}