diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-01-17 00:00:40 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-01-17 00:00:40 +0000 |
commit | 41f2b32df5faff10c305ef1892fcb02846e4f489 (patch) | |
tree | f045486ac563b6a3f6d374fc3c2d51a268e00dd2 | |
parent | f05b1520d6f175acbfc3913489f4dfa842875ec4 (diff) |
Catch a foreach parse error.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62382 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 5 | ||||
-rw-r--r-- | test/Parser/objc-foreach-syntax.m | 7 |
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index 8d4705a7bf..be929ae067 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -364,6 +364,11 @@ ParseInitDeclaratorListAfterFirstDeclarator(Declarator &D) { if (Tok.is(tok::semi)) { ConsumeToken(); + // for(is key; in keys) is error. + if (D.getContext() == Declarator::ForContext && isTokIdentifier_in()) { + Diag(Tok, diag::err_parse_error); + return 0; + } return Actions.FinalizeDeclaratorGroup(CurScope, LastDeclInGroup); } // If this is an ObjC2 for-each loop, this is a successful declarator diff --git a/test/Parser/objc-foreach-syntax.m b/test/Parser/objc-foreach-syntax.m new file mode 100644 index 0000000000..c00f7772e5 --- /dev/null +++ b/test/Parser/objc-foreach-syntax.m @@ -0,0 +1,7 @@ +// RUN: clang -fsyntax-only -verify %s + +static int test_NSURLGetResourceValueForKey( id keys ) +{ + for ( id key; in keys) { // expected-error {{parse error}} + } +} |