diff options
author | dim <dim@FreeBSD.org> | 2013-12-22 00:07:40 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2013-12-22 00:07:40 +0000 |
commit | 952eddef9aff85b1e92626e89baaf7a360e2ac85 (patch) | |
tree | df8df0b0067b381eab470a3b8f28d14a552a6340 /test/SemaCXX/for-range-examples.cpp | |
parent | ea266cad53e3d49771fa38103913d3ec7a166694 (diff) | |
download | FreeBSD-src-952eddef9aff85b1e92626e89baaf7a360e2ac85.zip FreeBSD-src-952eddef9aff85b1e92626e89baaf7a360e2ac85.tar.gz |
Vendor import of clang release_34 branch r197841 (effectively, 3.4 RC3):
https://llvm.org/svn/llvm-project/cfe/branches/release_34@197841
Diffstat (limited to 'test/SemaCXX/for-range-examples.cpp')
-rw-r--r-- | test/SemaCXX/for-range-examples.cpp | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/test/SemaCXX/for-range-examples.cpp b/test/SemaCXX/for-range-examples.cpp index 953c98b..b3cf9c3 100644 --- a/test/SemaCXX/for-range-examples.cpp +++ b/test/SemaCXX/for-range-examples.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 namespace value_range_detail { template<typename T> @@ -180,3 +180,32 @@ namespace test4 { for (y : {1, 2, 3}) {} // expected-error {{must declare a variable}} expected-warning {{result unused}} } } + +namespace test5 { + // Test error-recovery. + void f() { + for (auto x : undeclared_identifier) // expected-error {{undeclared identifier}} + for (auto y : x->foo) + y->bar(); + for (auto x : 123) // expected-error {{no viable 'begin'}} + 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 *'}} + } +} |