diff options
Diffstat (limited to 'clang/test/SemaCXX/for-range-examples.cpp')
-rw-r--r-- | clang/test/SemaCXX/for-range-examples.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/for-range-examples.cpp b/clang/test/SemaCXX/for-range-examples.cpp index 08c69368168..b3cf9c32642 100644 --- a/clang/test/SemaCXX/for-range-examples.cpp +++ b/clang/test/SemaCXX/for-range-examples.cpp @@ -191,3 +191,21 @@ namespace test5 { x->foo(); } } + +namespace test6 { + void foo(int arr[]) { // expected-note {{declared here}} + for (auto i : arr) { } + // expected-error@-1 {{cannot build range expression with array function parameter 'arr' since parameter with array type 'int []' is treated as pointer type 'int *'}} + } + + struct vector { + int *begin() { return 0; } + int *end() { return 0; } + }; + + void foo(vector arr[]) { // expected-note {{declared here}} + // Don't suggest to dereference arr. + for (auto i : arr) { } + // expected-error@-1 {{cannot build range expression with array function parameter 'arr' since parameter with array type 'test6::vector []' is treated as pointer type 'test6::vector *'}} + } +} |