]> granicus.if.org Git - clang/commitdiff
Make sure Parser::ParseObjCSelectorExpression() handles unary selectors (with no...
authorSteve Naroff <snaroff@apple.com>
Wed, 5 Dec 2007 22:21:29 +0000 (22:21 +0000)
committerSteve Naroff <snaroff@apple.com>
Wed, 5 Dec 2007 22:21:29 +0000 (22:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44636 91177308-0d34-0410-b5e6-96231b3b80d8

Parse/ParseObjc.cpp

index bc4bcbe901e1c2f4d0a6613db2a6b424b57b1793..88be2dc5fb7cccfdb1517136c17c09f0d2eb97cc 100644 (file)
@@ -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);
  }