diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-08-21 01:40:36 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-08-21 01:40:36 +0000 |
commit | 3249fed9b2c89f1e09b1f0bd9934472eaf316e6d (patch) | |
tree | 6bbd93934affaa4cc525429bb3b096b337f7074d /clang/test/SemaCXX/for-range-examples.cpp | |
parent | 84a0ae74b0f519a46f85495410ab2092718f55ba (diff) | |
download | bcm5719-llvm-3249fed9b2c89f1e09b1f0bd9934472eaf316e6d.tar.gz bcm5719-llvm-3249fed9b2c89f1e09b1f0bd9934472eaf316e6d.zip |
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.
llvm-svn: 188853
Diffstat (limited to 'clang/test/SemaCXX/for-range-examples.cpp')
-rw-r--r-- | clang/test/SemaCXX/for-range-examples.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/for-range-examples.cpp b/clang/test/SemaCXX/for-range-examples.cpp index ca505e02455..08c69368168 100644 --- a/clang/test/SemaCXX/for-range-examples.cpp +++ b/clang/test/SemaCXX/for-range-examples.cpp @@ -180,3 +180,14 @@ 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(); + } +} |