[cfe-commits] r115411 - in /cfe/trunk: clang.xcodeproj/project.pbxproj include/clang/Basic/DiagnosticParseKinds.td lib/Parse/ParseObjc.cpp test/SemaObjCXX/reserved-keyword-methods.mm
Anders Carlsson
andersca at mac.com
Sat Oct 2 10:45:21 PDT 2010
Author: andersca
Date: Sat Oct 2 12:45:21 2010
New Revision: 115411
URL: http://llvm.org/viewvc/llvm-project?rev=115411&view=rev
Log:
Use ParseObjCSelectorPiece for parsing getter and setter names in @property declarations. Fixes PR8169.
Modified:
cfe/trunk/clang.xcodeproj/project.pbxproj
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/test/SemaObjCXX/reserved-keyword-methods.mm
Modified: cfe/trunk/clang.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=115411&r1=115410&r2=115411&view=diff
==============================================================================
--- cfe/trunk/clang.xcodeproj/project.pbxproj (original)
+++ cfe/trunk/clang.xcodeproj/project.pbxproj Sat Oct 2 12:45:21 2010
@@ -2039,6 +2039,7 @@
isa = PBXProject;
buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
compatibilityVersion = "Xcode 2.4";
+ developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
English,
Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=115411&r1=115410&r2=115411&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Sat Oct 2 12:45:21 2010
@@ -218,8 +218,12 @@
def err_objc_illegal_visibility_spec : Error<
"illegal visibility specification">;
def err_objc_illegal_interface_qual : Error<"illegal interface qualifier">;
-def err_objc_expected_equal : Error<
- "setter/getter expects '=' followed by name">;
+def err_objc_expected_equal_for_getter : Error<
+ "expected '=' for Objective-C getter">;
+def err_objc_expected_equal_for_setter : Error<
+ "expected '=' for Objective-C setter">;
+def err_objc_expected_selector_for_getter_setter : Error<
+ "expected selector for Objective-C %select{setter|getter}0">;
def err_objc_property_requires_field_name : Error<
"property requires fields to be named">;
def err_objc_property_bitfield : Error<"property name cannot be a bitfield">;
Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=115411&r1=115410&r2=115411&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Sat Oct 2 12:45:21 2010
@@ -504,13 +504,17 @@
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 @@
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 @@
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;
Modified: cfe/trunk/test/SemaObjCXX/reserved-keyword-methods.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/reserved-keyword-methods.mm?rev=115411&r1=115410&r2=115411&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/reserved-keyword-methods.mm (original)
+++ cfe/trunk/test/SemaObjCXX/reserved-keyword-methods.mm Sat Oct 2 12:45:21 2010
@@ -34,8 +34,9 @@
#define DECLARE_METHOD(name) - (void)name;
-
+#define DECLARE_PROPERTY_WITH_GETTER(name) @property (getter=name) int prop_##name;
@interface A
-FOR_EACH_KEYWORD(DECLARE_METHOD)
+//FOR_EACH_KEYWORD(DECLARE_METHOD)
+FOR_EACH_KEYWORD(DECLARE_PROPERTY_WITH_GETTER)
@end
More information about the cfe-commits
mailing list