If we find an error in the range expression in a range-based for loop, and the
loop variable has a type containing 'auto', set the declaration to be invalid
(because we couldn't deduce its type) to prevent follow-on errors.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188853 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaCXX/for-range-examples.cpp b/test/SemaCXX/for-range-examples.cpp
index ca505e0..08c6936 100644
--- a/test/SemaCXX/for-range-examples.cpp
+++ b/test/SemaCXX/for-range-examples.cpp
@@ -180,3 +180,14 @@
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();
+ }
+}