diff options
author | Marek Polacek <polacek@redhat.com> | 2018-05-23 19:06:36 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2018-05-23 19:06:36 +0000 |
commit | 622075181d70d9dd3b0b0546447a167ac0ead6ba (patch) | |
tree | f64f93cf0416fc936f3284c4b58fe994d7906386 | |
parent | 89453706e0032f9a9c2107631873d9dad38dc14c (diff) | |
download | gcc-622075181d70d9dd3b0b0546447a167ac0ead6ba.zip gcc-622075181d70d9dd3b0b0546447a167ac0ead6ba.tar.gz gcc-622075181d70d9dd3b0b0546447a167ac0ead6ba.tar.bz2 |
range-for8.C: New test.
* g++.dg/cpp2a/range-for8.C: New test.
* g++.dg/cpp2a/range-for9.C: New test.
* g++.dg/cpp2a/range-for10.C: New test.
From-SVN: r260625
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp2a/range-for10.C | 24 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp2a/range-for8.C | 37 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp2a/range-for9.C | 30 |
4 files changed, 97 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e9b35d5..01bc8b1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2018-05-23 Marek Polacek <polacek@redhat.com> + + * g++.dg/cpp2a/range-for8.C: New test. + * g++.dg/cpp2a/range-for9.C: New test. + * g++.dg/cpp2a/range-for10.C: New test. + 2017-05-23 Segher Boessenkool <segher@kernel.crashing.org> * lib/target-supports.exp (check_effective_target_be): New. diff --git a/gcc/testsuite/g++.dg/cpp2a/range-for10.C b/gcc/testsuite/g++.dg/cpp2a/range-for10.C new file mode 100644 index 0000000..a0d0e6d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/range-for10.C @@ -0,0 +1,24 @@ +// P0614R1 +// { dg-do run } +// { dg-options "-std=c++2a" } + +struct A { int i; long long j; } a[64]; + +int +main () +{ + A b = { 1, 2 }; + for (auto & [ u, v ] : a) + { + u = 2; + v = 3; + } + + for (auto [x, y] = b; auto [ u, v ] : a) + if (y + u != x + v) + __builtin_abort (); + + for (auto [x, y] = b; auto & [ u, v ] : a) + if (y + u != x + v) + __builtin_abort (); +} diff --git a/gcc/testsuite/g++.dg/cpp2a/range-for8.C b/gcc/testsuite/g++.dg/cpp2a/range-for8.C new file mode 100644 index 0000000..204a632 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/range-for8.C @@ -0,0 +1,37 @@ +// P0614R1 +// { dg-do run } +// { dg-options "-std=c++2a" } + +struct A { int i; long long j; } a[64]; + +int +main () +{ + for (int i = 0; auto &x : a) + { + x.i = i; + x.j = 2 * i++; + } + for (auto & [ x, y ] : a) + { + x += 2; + y += 3; + } + for (int i = 0; const auto [ u, v ] : a) + { + if (u != i + 2 || v != 2 * i++ + 3) + __builtin_abort (); + } + for (int i = 0; auto [ x, y ] : a) + { + x += 4; + y += 5; + if (x != i + 6 || y != 2 * i++ + 8) + __builtin_abort (); + } + for (int i = 0; const auto x : a) + { + if (x.i != i + 2 || x.j != 2 * i++ + 3) + __builtin_abort (); + } +} diff --git a/gcc/testsuite/g++.dg/cpp2a/range-for9.C b/gcc/testsuite/g++.dg/cpp2a/range-for9.C new file mode 100644 index 0000000..74d71b6 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/range-for9.C @@ -0,0 +1,30 @@ +// P0614R1 +// { dg-do run } +// { dg-options "-std=c++2a" } + +struct A { int i, j; }; + +int +main () +{ + A a = { .i = 2, .j = 3 }; + int arr[] = { 1, 1, 1 }; + + for (auto & [ x, y ] = a; auto z : arr) + if (x + z != 3 || y + z != 4) + __builtin_abort (); + + for (int d = 1; auto &z : arr) + z += d; + + for (const auto [ x, y ] = a; auto z : arr) + if (x + z != 4 || y + z != 5) + __builtin_abort (); + + for (int d = 1; auto &z : arr) + z += d; + + for (auto [ x, y ] = a; auto z : arr) + if (x + z != 5 || y + z != 6) + __builtin_abort (); +} |