diff options
author | Anders Carlsson <andersca@mac.com> | 2010-10-02 17:45:21 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2010-10-02 17:45:21 +0000 |
commit | fe15a78ff24fe62b1da2fa5b834c6b7501a6cc95 (patch) | |
tree | 17223e63ee8c751de69e0a12ea530378941a7564 /clang/lib/Parse/ParseObjc.cpp | |
parent | 0e523cba82e93c1d842e885f175ff4cd9018f719 (diff) | |
download | bcm5719-llvm-fe15a78ff24fe62b1da2fa5b834c6b7501a6cc95.tar.gz bcm5719-llvm-fe15a78ff24fe62b1da2fa5b834c6b7501a6cc95.zip |
Use ParseObjCSelectorPiece for parsing getter and setter names in @property declarations. Fixes PR8169.
llvm-svn: 115411
Diffstat (limited to 'clang/lib/Parse/ParseObjc.cpp')
-rw-r--r-- | clang/lib/Parse/ParseObjc.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/clang/lib/Parse/ParseObjc.cpp b/clang/lib/Parse/ParseObjc.cpp index 3291736acc0..09053e28cc4 100644 --- a/clang/lib/Parse/ParseObjc.cpp +++ b/clang/lib/Parse/ParseObjc.cpp @@ -504,13 +504,17 @@ void Parser::ParseObjCPropertyAttribute(ObjCDeclSpec &DS, Decl *ClassDecl, else if (II->isStr("nonatomic")) DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_nonatomic); else if (II->isStr("getter") || II->isStr("setter")) { + bool IsSetter = II->getNameStart()[0] == 's'; + // getter/setter require extra treatment. - if (ExpectAndConsume(tok::equal, diag::err_objc_expected_equal, "", - tok::r_paren)) + unsigned DiagID = IsSetter ? diag::err_objc_expected_equal_for_setter : + diag::err_objc_expected_equal_for_getter; + + if (ExpectAndConsume(tok::equal, DiagID, "", tok::r_paren)) return; if (Tok.is(tok::code_completion)) { - if (II->getNameStart()[0] == 's') + if (IsSetter) Actions.CodeCompleteObjCPropertySetter(getCurScope(), ClassDecl, Methods, NumMethods); else @@ -519,16 +523,20 @@ void Parser::ParseObjCPropertyAttribute(ObjCDeclSpec &DS, Decl *ClassDecl, ConsumeCodeCompletionToken(); } - if (Tok.isNot(tok::identifier)) { - Diag(Tok, diag::err_expected_ident); + + SourceLocation SelLoc; + IdentifierInfo *SelIdent = ParseObjCSelectorPiece(SelLoc); + + if (!SelIdent) { + Diag(Tok, diag::err_objc_expected_selector_for_getter_setter) + << IsSetter; SkipUntil(tok::r_paren); return; } - if (II->getNameStart()[0] == 's') { + if (IsSetter) { DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_setter); - DS.setSetterName(Tok.getIdentifierInfo()); - ConsumeToken(); // consume method name + DS.setSetterName(SelIdent); if (ExpectAndConsume(tok::colon, diag::err_expected_colon_after_setter_name, "", @@ -536,8 +544,7 @@ void Parser::ParseObjCPropertyAttribute(ObjCDeclSpec &DS, Decl *ClassDecl, return; } else { DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_getter); - DS.setGetterName(Tok.getIdentifierInfo()); - ConsumeToken(); // consume method name + DS.setGetterName(SelIdent); } } else { Diag(AttrName, diag::err_objc_expected_property_attr) << II; |