summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp0x/range-for1.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/cpp0x/range-for1.C')
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/range-for1.C17
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp0x/range-for1.C b/gcc/testsuite/g++.dg/cpp0x/range-for1.C
new file mode 100644
index 000000000..49e2ecd0b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/range-for1.C
@@ -0,0 +1,17 @@
+// Test for range-based for loop
+// Test the loop with an array
+
+// { dg-do run }
+// { dg-options "-std=c++0x" }
+
+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();
+}