diff options
author | Steve Naroff <snaroff@apple.com> | 2007-12-05 22:21:29 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2007-12-05 22:21:29 +0000 |
commit | 887407e71fd58de452361b77d72970e32b20ebe0 (patch) | |
tree | 1960d3e95eb36fb5c7dd77e111059a9845a1f156 | |
parent | 665dd4a40e0e38657f7bf26c2e3490304e5c7510 (diff) |
Make sure Parser::ParseObjCSelectorExpression() handles unary selectors (with no arguments) properly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44636 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | Parse/ParseObjc.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Parse/ParseObjc.cpp b/Parse/ParseObjc.cpp index bc4bcbe901..88be2dc5fb 100644 --- a/Parse/ParseObjc.cpp +++ b/Parse/ParseObjc.cpp @@ -1401,17 +1401,18 @@ Parser::ExprResult Parser::ParseObjCSelectorExpression(SourceLocation AtLoc) SourceLocation sLoc; IdentifierInfo *SelIdent = ParseObjCSelector(sLoc); if (!SelIdent && Tok.isNot(tok::colon)) { - Diag(Tok, diag::err_expected_ident); // missing selector name. return 0; } KeyIdents.push_back(SelIdent); - if (Tok.isNot(tok::r_paren)) + unsigned nColons = 0; + if (Tok.isNot(tok::r_paren)) { while (1) { if (Tok.isNot(tok::colon)) { Diag(Tok, diag::err_expected_colon); break; } + nColons++; ConsumeToken(); // Eat the ':'. if (Tok.is(tok::r_paren)) break; @@ -1422,9 +1423,9 @@ Parser::ExprResult Parser::ParseObjCSelectorExpression(SourceLocation AtLoc) if (!SelIdent && Tok.isNot(tok::colon)) break; } + } SourceLocation RParenLoc = MatchRHSPunctuation(tok::r_paren, LParenLoc); - Selector Sel = PP.getSelectorTable().getSelector(KeyIdents.size(), - &KeyIdents[0]); + Selector Sel = PP.getSelectorTable().getSelector(nColons, &KeyIdents[0]); return Actions.ParseObjCSelectorExpression(Sel, AtLoc, SelectorLoc, LParenLoc, RParenLoc); } |