Better diagnostics for range-based for loops with bad range types.
The old error message stating that 'begin' was an undeclared identifier
is replaced with a new message explaining that the error is in the range
expression, along with which of the begin() and end() functions was
problematic if relevant.
Additionally, if the range was a pointer type or defines operator*,
attempt to dereference the range, and offer a FixIt if the modified range
works.
llvm-svn: 162248
diff --git a/clang/test/SemaCXX/for-range-no-std.cpp b/clang/test/SemaCXX/for-range-no-std.cpp
index fa42ca4..66b445e 100644
--- a/clang/test/SemaCXX/for-range-no-std.cpp
+++ b/clang/test/SemaCXX/for-range-no-std.cpp
@@ -31,10 +31,10 @@
void f() {
int a[] = {1, 2, 3};
for (auto b : S()) {} // ok
- for (auto b : T()) {} // expected-error {{no matching function for call to 'begin'}} expected-note {{range has type}}
+ for (auto b : T()) {} // expected-error {{invalid range expression of type 'T'}}
for (auto b : a) {} // ok
for (int b : NS::ADL()) {} // ok
- for (int b : NS::NoADL()) {} // expected-error {{no matching function for call to 'begin'}} expected-note {{range has type}}
+ for (int b : NS::NoADL()) {} // expected-error {{invalid range expression of type 'NS::NoADL'}}
}
void PR11601() {