From: Steve Naroff Date: Wed, 5 Dec 2007 22:21:29 +0000 (+0000) Subject: Make sure Parser::ParseObjCSelectorExpression() handles unary selectors (with no... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=887407e71fd58de452361b77d72970e32b20ebe0;p=clang 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 --- 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); }