Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/g++.dg/cpp2a/range-for15.C @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
1 // PR c++/87152 | |
2 // { dg-do run } | |
3 // { dg-options "-std=c++2a" } | |
4 | |
5 struct A { int i; long long j; } a[64]; | |
6 | |
7 template<typename T> | |
8 void foo () | |
9 { | |
10 for (T i = 0; auto &x : a) | |
11 { | |
12 x.i = i; | |
13 x.j = 2 * i++; | |
14 } | |
15 for (auto & [ x, y ] : a) | |
16 { | |
17 x += 2; | |
18 y += 3; | |
19 } | |
20 for (T i = 0; const auto [ u, v ] : a) | |
21 { | |
22 if (u != i + 2 || v != 2 * i++ + 3) | |
23 __builtin_abort (); | |
24 } | |
25 for (T i = 0; auto [ x, y ] : a) | |
26 { | |
27 x += 4; | |
28 y += 5; | |
29 if (x != i + 6 || y != 2 * i++ + 8) | |
30 __builtin_abort (); | |
31 } | |
32 for (T i = 0; const auto x : a) | |
33 { | |
34 if (x.i != i + 2 || x.j != 2 * i++ + 3) | |
35 __builtin_abort (); | |
36 } | |
37 } | |
38 | |
39 int | |
40 main () | |
41 { | |
42 foo<int>(); | |
43 } |