summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/for-range-dereference.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-09-20 21:52:32 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-09-20 21:52:32 +0000
commita05b3b5435a130d36798835980c9374636152ecf (patch)
treeb02a04caa7d3b4f760aa3ad75ddbfa0495189e6d /clang/test/SemaCXX/for-range-dereference.cpp
parent0c9773c6d5d452d9fc070859776657df44584bd8 (diff)
downloadbcm5719-llvm-a05b3b5435a130d36798835980c9374636152ecf.tar.gz
bcm5719-llvm-a05b3b5435a130d36798835980c9374636152ecf.zip
If the range in a for range statement doesn't have a viable begin/end function,
but can be dereferenced to form an expression which does have viable begin/end functions, then typo-correct the range, even if something else goes wrong with the statement (such as inaccessible begin/end or the wrong type of loop variable). In order to ensure we recover correctly and produce any followup diagnostics in this case, redo semantic analysis on the for-range statement outside of the diagnostic trap, after issuing the typo-correction. llvm-svn: 164323
Diffstat (limited to 'clang/test/SemaCXX/for-range-dereference.cpp')
-rw-r--r--clang/test/SemaCXX/for-range-dereference.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/clang/test/SemaCXX/for-range-dereference.cpp b/clang/test/SemaCXX/for-range-dereference.cpp
index 3bf50f33300..bf3187da30e 100644
--- a/clang/test/SemaCXX/for-range-dereference.cpp
+++ b/clang/test/SemaCXX/for-range-dereference.cpp
@@ -17,17 +17,17 @@ struct DeletedEnd : public T {
struct DeletedADLBegin { };
int* begin(DeletedADLBegin) = delete; //expected-note {{candidate function has been explicitly deleted}} \
- expected-note 6 {{candidate function not viable: no known conversion}}
+ expected-note 5 {{candidate function not viable: no known conversion}}
struct PrivateEnd {
Data *begin();
private:
- Data *end(); // expected-note 1 {{declared private here}}
+ Data *end(); // expected-note 2 {{declared private here}}
};
struct ADLNoEnd { };
-Data * begin(ADLNoEnd); // expected-note 7 {{candidate function not viable: no known conversion}}
+Data * begin(ADLNoEnd); // expected-note 6 {{candidate function not viable: no known conversion}}
struct OverloadedStar {
T operator*();
@@ -70,10 +70,9 @@ expected-note {{when looking up 'end' function for range expression of type 'Del
// the range is invalid.
for (auto i : PE) { } // expected-error{{'end' is a private member of 'PrivateEnd'}}
- // FIXME: This diagnostic should be improved as well. It should not mention a
- // deleted function, and we should not issue a FixIt suggesting a dereference.
PrivateEnd *pPE;
for (auto i : pPE) { }// expected-error {{invalid range expression of type 'PrivateEnd *'}}
+ // expected-error@-1 {{'end' is a private member of 'PrivateEnd'}}
DeletedADLBegin DAB;
for (auto i : DAB) { } // expected-error {{call to deleted function 'begin'}}\
@@ -83,4 +82,8 @@ expected-note {{when looking up 'end' function for range expression of type 'Del
for (auto i : *OS) { }
for (auto i : OS) { } // expected-error {{invalid range expression of type 'OverloadedStar'; did you mean to dereference it with '*'?}}
+
+ for (Data *p : pt) { } // expected-error {{invalid range expression of type 'T *'; did you mean to dereference it with '*'?}}
+ // expected-error@-1 {{no viable conversion from 'Data' to 'Data *'}}
+ // expected-note@4 {{selected 'begin' function with iterator type 'Data *'}}
}
OpenPOWER on IntegriCloud