]> granicus.if.org Git - clang/commitdiff
- Cleanup "hack" comment and fix typos.
authorSteve Naroff <snaroff@apple.com>
Thu, 23 Aug 2007 19:56:30 +0000 (19:56 +0000)
committerSteve Naroff <snaroff@apple.com>
Thu, 23 Aug 2007 19:56:30 +0000 (19:56 +0000)
- Use getLang().ObjC2 when appropriate.

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

Parse/ParseObjc.cpp
Parse/Parser.cpp

index 803d820b21b49bbb8b8035aeb355676784b9d873..4b3c60079466086c35aaee361e5b9c63bf74369f 100644 (file)
@@ -122,15 +122,18 @@ Parser::DeclTy *Parser::ParseObjCAtInterfaceDeclaration(
   IdentifierInfo *nameId = Tok.getIdentifierInfo();
   SourceLocation nameLoc = ConsumeToken();
   
-  if (Tok.getKind() == tok::l_paren) { // we have a category
+  if (Tok.getKind() == tok::l_paren) { // we have a category.
     SourceLocation lparenLoc = ConsumeParen();
     SourceLocation categoryLoc, rparenLoc;
     IdentifierInfo *categoryId = 0;
     
-    // OBJC2: The cateogry name is optional (not an error).
+    // For ObjC2, the category name is optional (not an error).
     if (Tok.getKind() == tok::identifier) {
       categoryId = Tok.getIdentifierInfo();
       categoryLoc = ConsumeToken();
+    } else if (!getLang().ObjC2) {
+      Diag(Tok, diag::err_expected_ident); // missing category name.
+      return 0;
     }
     if (Tok.getKind() != tok::r_paren) {
       Diag(Tok, diag::err_expected_rparen);
@@ -268,7 +271,7 @@ void Parser::ParseObjCMethodPrototype() {
   ParseObjCMethodDecl(methodType, methodLoc);
   
   // If attributes exist after the method, parse them.
-  if (Tok.getKind() == tok::kw___attribute)
+  if (getLang().ObjC2 && Tok.getKind() == tok::kw___attribute)
     ParseAttributes();
     
   // Consume the ';'.
@@ -387,7 +390,7 @@ void Parser::ParseObjCMethodDecl(tok::TokenKind mType, SourceLocation mLoc) {
         ParseObjCTypeName();
 
       // If attributes exist before the argument name, parse them.
-      if (Tok.getKind() == tok::kw___attribute)
+      if (getLang().ObjC2 && Tok.getKind() == tok::kw___attribute)
         ParseAttributes();
 
       if (Tok.getKind() != tok::identifier) {
index 6ee190ebf562dc53fff9b148a0f26c3a018124cf..e4f1138521191f12ff373023ae11555bef90880d 100644 (file)
@@ -370,8 +370,8 @@ Parser::DeclTy *Parser::ParseDeclarationOrFunctionDefinition() {
     return Actions.ParsedFreeStandingDeclSpec(CurScope, DS);
   }
   
-  // OBJC: This grammar hack allows prefix attributes on class interfaces.
-  if (Tok.getKind() == tok::at) {
+  // ObjC2 allows prefix attributes on class interfaces.
+  if (getLang().ObjC2 && Tok.getKind() == tok::at) {
     SourceLocation AtLoc = ConsumeToken(); // the "@"
     if (Tok.getIdentifierInfo()->getObjCKeywordID() == tok::objc_interface)
       return ParseObjCAtInterfaceDeclaration(AtLoc, DS.getAttributes());