[cfe-commits] r57812 - in /cfe/trunk: include/clang/Basic/DiagnosticKinds.def lib/Parse/ParseObjc.cpp

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


Author: lattner
Date: Mon Oct 20 02:22:18 2008
New Revision: 57812

URL: http://llvm.org/viewvc/llvm-project?rev=57812&view=rev
Log:
reject properties completely in objc1 instead of emitting 
weird errors about property attributes being unknown.


Modified:
    cfe/trunk/include/clang/Basic/DiagnosticKinds.def
    cfe/trunk/lib/Parse/ParseObjc.cpp

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

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Mon Oct 20 02:22:18 2008
@@ -422,6 +422,8 @@
      "property requires fields to be named")
 DIAG(err_objc_expected_property_attr, ERROR,
      "unknown property attribute '%0'")
+DIAG(err_objc_propertoes_require_objc2, ERROR,
+     "properties are an Objective-C 2 feature")
 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/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=57812&r1=57811&r2=57812&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Mon Oct 20 02:22:18 2008
@@ -283,7 +283,7 @@
       // continue to eat up tons of stuff and spew lots of nonsense errors.  It
       // would probably be better to bail out if we saw an @class or @interface
       // or something like that.
-      Diag(Tok, diag::err_objc_illegal_interface_qual);
+      Diag(AtLoc, diag::err_objc_illegal_interface_qual);
       // Skip until we see an '@' or '}' or ';'.
       SkipUntil(tok::r_brace, tok::at);
       break;
@@ -299,10 +299,14 @@
       break;
         
     case tok::objc_property:
+      if (!getLang().ObjC2)
+        Diag(AtLoc, diag::err_objc_propertoes_require_objc2);
+
       ObjCDeclSpec OCDS;
       // Parse property attribute list, if any. 
-      if (Tok.is(tok::l_paren))
+      if (Tok.is(tok::l_paren)) {
         ParseObjCPropertyAttribute(OCDS);
+      }
         
       // Parse all the comma separated declarators.
       DeclSpec DS;
@@ -379,6 +383,13 @@
   
   while (1) {
     const IdentifierInfo *II = Tok.getIdentifierInfo();
+    
+    // If this is not an identifier at all, bail out early.
+    if (II == 0) {
+      MatchRHSPunctuation(tok::r_paren, LHSLoc);
+      return;
+    }
+    
     // getter/setter require extra treatment.
     if (II == ObjCPropertyAttrs[objc_getter] || 
         II == ObjCPropertyAttrs[objc_setter]) {
@@ -416,21 +427,18 @@
     else if (II == ObjCPropertyAttrs[objc_assign])
       DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_assign);
     else if (II == ObjCPropertyAttrs[objc_readwrite])
-        DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_readwrite);
+      DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_readwrite);
     else if (II == ObjCPropertyAttrs[objc_retain])
       DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_retain);
     else if (II == ObjCPropertyAttrs[objc_copy])
       DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_copy);
     else if (II == ObjCPropertyAttrs[objc_nonatomic])
       DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_nonatomic);
-    else if (II) {
+    else {
       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





More information about the cfe-commits mailing list