diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-02-21 20:01:35 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-02-21 20:01:35 +0000 |
commit | e38fa1866e684b99c6c6e359449af9e0b6e83164 (patch) | |
tree | deb072152dce1b63648b61578dc6ca994e460666 /test/SemaCXX | |
parent | f57c413e444b441fa75ae8911d183c19b53bdd56 (diff) |
Don't assume that a valid expression for the first part of a for-statement
is non-null when diagnosing a broken attempt to write a for-range-statement.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151081 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX')
-rw-r--r-- | test/SemaCXX/for-range-examples.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/SemaCXX/for-range-examples.cpp b/test/SemaCXX/for-range-examples.cpp index 868de9d4f0..8bda51062a 100644 --- a/test/SemaCXX/for-range-examples.cpp +++ b/test/SemaCXX/for-range-examples.cpp @@ -169,3 +169,14 @@ namespace test3 { template<typename T> void f() { for (auto a : A()) {} } void g() { f<int>(); } } + +namespace test4 { + void f() { + int y; + + // Make sure these don't crash. Better diagnostics would be nice. + for (: {1, 2, 3}) {} // expected-error {{expected expression}} expected-error {{expected ';'}} + for (x : {1, 2, 3}) {} // expected-error {{undeclared identifier}} expected-error {{expected ';'}} + for (y : {1, 2, 3}) {} // expected-error {{must declare a variable}} expected-warning {{result unused}} + } +} |