diff options
Diffstat (limited to 'gcc-4.9/gcc/testsuite/g++.dg/cpp0x/range-for1.C')
-rw-r--r-- | gcc-4.9/gcc/testsuite/g++.dg/cpp0x/range-for1.C | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/range-for1.C b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/range-for1.C new file mode 100644 index 0000000..4fecdc7 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/range-for1.C @@ -0,0 +1,16 @@ +// Test for range-based for loop +// Test the loop with an array + +// { dg-do run { target c++11 } } + +extern "C" void abort(); + +int main() +{ + int a[] = {1,2,3,4}; + int sum = 0; + for (int x : a) + sum += x; + if (sum != 10) + abort(); +} |