]> granicus.if.org Git - clang/commitdiff
Class Property: parse @dynamic (class).
authorManman Ren <manman.ren@gmail.com>
Fri, 29 Jan 2016 19:05:57 +0000 (19:05 +0000)
committerManman Ren <manman.ren@gmail.com>
Fri, 29 Jan 2016 19:05:57 +0000 (19:05 +0000)
rdar://23891898

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@259224 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseObjc.cpp
test/SemaObjC/objc-class-property.m

index 0f2c3a43672e27e72737cee938652a50a74bdf76..5cd7e7ab7e81d37df94cc6a1525e874409fa3f78 100644 (file)
@@ -2353,6 +2353,31 @@ Decl *Parser::ParseObjCPropertyDynamic(SourceLocation atLoc) {
   assert(Tok.isObjCAtKeyword(tok::objc_dynamic) &&
          "ParseObjCPropertyDynamic(): Expected '@dynamic'");
   ConsumeToken(); // consume dynamic
+
+  bool isClassProperty = false;
+  if (Tok.is(tok::l_paren)) {
+    ConsumeParen();
+    const IdentifierInfo *II = Tok.getIdentifierInfo();
+
+    if (!II) {
+      Diag(Tok, diag::err_objc_expected_property_attr) << II;
+      SkipUntil(tok::r_paren, StopAtSemi);
+    } else {
+      SourceLocation AttrName = ConsumeToken(); // consume attribute name
+      if (II->isStr("class")) {
+        isClassProperty = true;
+        if (Tok.isNot(tok::r_paren)) {
+          Diag(Tok, diag::err_expected) << tok::r_paren;
+          SkipUntil(tok::r_paren, StopAtSemi);
+        } else
+          ConsumeParen();
+      } else {
+        Diag(AttrName, diag::err_objc_expected_property_attr) << II;
+        SkipUntil(tok::r_paren, StopAtSemi);
+      }
+    }
+  }
+
   while (true) {
     if (Tok.is(tok::code_completion)) {
       Actions.CodeCompleteObjCPropertyDefinition(getCurScope());
@@ -2371,6 +2396,7 @@ Decl *Parser::ParseObjCPropertyDynamic(SourceLocation atLoc) {
     Actions.ActOnPropertyImplDecl(
         getCurScope(), atLoc, propertyLoc, false,
         propertyId, nullptr, SourceLocation(),
+        isClassProperty ? ObjCPropertyQueryKind::OBJC_PR_query_class :
         ObjCPropertyQueryKind::OBJC_PR_query_unknown);
 
     if (Tok.isNot(tok::comma))
index bc2bf25193de80bd73c9d3c02b45568ff8dc24ce..449f106964b1c4422f142d674224a826cc59f374 100644 (file)
 @end
 
 @implementation A
-@dynamic x;
+@dynamic x; // refers to the instance property
+@dynamic (class) x; // refers to the class property
 @synthesize z;
-@dynamic c;
+@dynamic c; // refers to the class property
 @end
 
 int test() {