diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-04-14 22:09:26 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-04-14 22:09:26 +0000 |
commit | ad762fcdc16b9e4705b12b09d92b8c026212b906 (patch) | |
tree | 333a2f586a7315091735e7addbff7346f5dae0f7 /test/PCH | |
parent | ea698b3f6cad84f7f583282dce3e03e24fe80e98 (diff) | |
download | clang-ad762fcdc16b9e4705b12b09d92b8c026212b906.tar.gz |
Add support for C++0x's range-based for loops, as specified by the C++11 draft standard (N3291).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129541 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/PCH')
-rw-r--r-- | test/PCH/cxx-for-range.cpp | 19 | ||||
-rw-r--r-- | test/PCH/cxx-for-range.h | 35 |
2 files changed, 54 insertions, 0 deletions
diff --git a/test/PCH/cxx-for-range.cpp b/test/PCH/cxx-for-range.cpp new file mode 100644 index 0000000000..5854917da5 --- /dev/null +++ b/test/PCH/cxx-for-range.cpp @@ -0,0 +1,19 @@ +// Test this without pch. +// RUN: %clang_cc1 -std=c++0x -include %S/cxx-for-range.h -fsyntax-only -emit-llvm -o - %s + +// Test with pch. +// RUN: %clang_cc1 -std=c++0x -emit-pch -o %t %S/cxx-for-range.h +// RUN: %clang_cc1 -std=c++0x -include-pch %t -fsyntax-only -emit-llvm -o - %s + +void h() { + f(); + + g<int>(); + + char a[3] = { 0, 1, 2 }; + for (auto w : a) + for (auto x : S()) + for (auto y : T()) + for (auto z : U()) + ; +} diff --git a/test/PCH/cxx-for-range.h b/test/PCH/cxx-for-range.h new file mode 100644 index 0000000000..f15c7e73df --- /dev/null +++ b/test/PCH/cxx-for-range.h @@ -0,0 +1,35 @@ +// Header for PCH test cxx-for-range.cpp + +struct S { + int *begin(); + int *end(); +}; + +struct T { }; +char *begin(T); +char *end(T); + +struct U { }; +namespace std { + char *begin(U); + char *end(U); +} + +void f() { + char a[3] = { 0, 1, 2 }; + for (auto w : a) + for (auto x : S()) + for (auto y : T()) + for (auto z : U()) + ; +} + +template<typename A> +void g() { + A a[3] = { 0, 1, 2 }; + for (auto &v : a) + for (auto x : S()) + for (auto y : T()) + for (auto z : U()) + ; +} |