[cfe-commits] r57811 - in /cfe/trunk: include/clang/Basic/DiagnosticKinds.def include/clang/Parse/Parser.h lib/Parse/ParseObjc.cpp test/SemaObjC/property-9.m

Chris Lattner sabre at nondot.org
Mon Oct 20 00:15:22 PDT 2008


Author: lattner
Date: Mon Oct 20 02:15:22 2008
New Revision: 57811

URL: http://llvm.org/viewvc/llvm-project?rev=57811&view=rev
Log:
More property attribute recovery improvements.  Instead of this:

crash.m:8:12: error: type name requires a specifier or qualifier
@property (readonlyx, getter=isAwesome) int _awesome;
           ^
crash.m:8:29: error: expected ';' at end of declaration list
@property (readonlyx, getter=isAwesome) int _awesome;
                            ^
crash.m:8:39: error: expected identifier or '('
@property (readonlyx, getter=isAwesome) int _awesome;
                                      ^

we now get:

crash.m:8:12: error: unknown property attribute 'readonlyx'
@property (readonlyx, getter=isAwesome) int _awesome;
           ^

Also, we can eliminate isObjCPropertyAttribute now.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticKinds.def
    cfe/trunk/include/clang/Parse/Parser.h
    cfe/trunk/lib/Parse/ParseObjc.cpp
    cfe/trunk/test/SemaObjC/property-9.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=57811&r1=57810&r2=57811&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Mon Oct 20 02:15:22 2008
@@ -419,9 +419,9 @@
 DIAG(err_objc_expected_equal, ERROR,
      "setter/getter expects '=' followed by name")
 DIAG(err_objc_property_requires_field_name, ERROR,
-     "@property requires fields to be named")
+     "property requires fields to be named")
 DIAG(err_objc_expected_property_attr, ERROR,
-     "unknown property attribute detected")
+     "unknown property attribute '%0'")
 DIAG(err_objc_unexpected_attr, ERROR,
      "prefix attribute must be followed by an interface or protocol")
 DIAG(err_objc_property_attr_mutually_exclusive, ERROR,

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=57811&r1=57810&r2=57811&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Mon Oct 20 02:15:22 2008
@@ -396,7 +396,6 @@
     objc_readwrite, objc_retain, objc_copy, objc_nonatomic, objc_NumAttrs
   };
   IdentifierInfo *ObjCPropertyAttrs[objc_NumAttrs];
-  bool isObjCPropertyAttribute();
   
   bool isTokIdentifier_in() const;
 

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=57811&r1=57810&r2=57811&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Mon Oct 20 02:15:22 2008
@@ -377,7 +377,7 @@
 void Parser::ParseObjCPropertyAttribute(ObjCDeclSpec &DS) {
   SourceLocation LHSLoc = ConsumeParen(); // consume '('
   
-  while (isObjCPropertyAttribute()) {
+  while (1) {
     const IdentifierInfo *II = Tok.getIdentifierInfo();
     // getter/setter require extra treatment.
     if (II == ObjCPropertyAttrs[objc_getter] || 
@@ -393,7 +393,7 @@
             loc = ConsumeToken();  // consume method name
             if (Tok.isNot(tok::colon)) {
               Diag(loc, diag::err_expected_colon);
-              SkipUntil(tok::r_paren,true,true);
+              SkipUntil(tok::r_paren);
               return;
             }
           } else {
@@ -402,13 +402,13 @@
           }
         } else {
           Diag(loc, diag::err_expected_ident);
-          SkipUntil(tok::r_paren,true,true);
+          SkipUntil(tok::r_paren);
           return;
         }
       }
       else {
         Diag(loc, diag::err_objc_expected_equal);    
-        SkipUntil(tok::r_paren,true,true);
+        SkipUntil(tok::r_paren);
         return;
       }
     } else if (II == ObjCPropertyAttrs[objc_readonly])
@@ -423,6 +423,15 @@
       DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_copy);
     else if (II == ObjCPropertyAttrs[objc_nonatomic])
       DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_nonatomic);
+    else if (II) {
+      Diag(Tok.getLocation(), diag::err_objc_expected_property_attr,
+           II->getName());
+      SkipUntil(tok::r_paren);
+      return;
+    } else {
+      MatchRHSPunctuation(tok::r_paren, LHSLoc);
+      return;
+    }
     
     ConsumeToken(); // consume last attribute token
     if (Tok.is(tok::comma)) {
@@ -550,18 +559,6 @@
   }
 }
 
-///  property-attrlist: one of
-///    readonly getter setter assign retain copy nonatomic
-///
-bool Parser::isObjCPropertyAttribute() {
-  if (Tok.is(tok::identifier)) {
-    const IdentifierInfo *II = Tok.getIdentifierInfo();
-    for (unsigned i = 0; i < objc_NumAttrs; ++i)
-      if (II == ObjCPropertyAttrs[i]) return true;
-  }
-  return false;
-} 
-
 ///  objc-for-collection-in: 'in'
 ///
 bool Parser::isTokIdentifier_in() const {

Modified: cfe/trunk/test/SemaObjC/property-9.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-9.m?rev=57811&r1=57810&r2=57811&view=diff

==============================================================================
--- cfe/trunk/test/SemaObjC/property-9.m (original)
+++ cfe/trunk/test/SemaObjC/property-9.m Mon Oct 20 02:15:22 2008
@@ -53,6 +53,12 @@
 @property (readonly getter=isAwesome) // expected-error {{error: expected ')'}}  \
                                       // expected-error {{to match this '('}}
   int _awesome;
+ at property (readonlyx) // expected-error {{unknown property attribute 'readonlyx'}}
+  int _awesome2;
+
+ at property (+)  // expected-error {{error: expected ')'}}  \
+               // expected-error {{to match this '('}}
+  int _awesome3;
 
 @end
 





More information about the cfe-commits mailing list