[cfe-commits] r39099 - /cfe/cfe/trunk/Parse/Parser.cpp

sabre at cs.uiuc.edu sabre at cs.uiuc.edu
Wed Jul 11 09:27:31 PDT 2007


Author: sabre
Date: Wed Jul 11 11:27:31 2007
New Revision: 39099

URL: http://llvm.org/viewvc/llvm-project?rev=39099&view=rev
Log:
Fix case stmts to not fall through, rename methods, assert on unimplemented
pieces, emit a diagnostic like this:

test.m:4:1: error: unexpected '@' in program
@ foo;
^

Modified:
    cfe/cfe/trunk/Parse/Parser.cpp

Modified: cfe/cfe/trunk/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Parse/Parser.cpp?rev=39099&r1=39098&r2=39099&view=diff

==============================================================================
--- cfe/cfe/trunk/Parse/Parser.cpp (original)
+++ cfe/cfe/trunk/Parse/Parser.cpp Wed Jul 11 11:27:31 2007
@@ -292,7 +292,7 @@
     return 0;
   case tok::minus:
     ObjCParseInstanceMethodDeclaration();
-	return 0;
+    return 0;
   case tok::plus:
     ObjCParseClassMethodDeclaration();
     return 0;
@@ -454,26 +454,25 @@
 }
 
 void Parser::ObjCParseAtDirectives() {
-  SourceLocation atLoc = ConsumeToken(); // the "@"
+  SourceLocation AtLoc = ConsumeToken(); // the "@"
 
   IdentifierInfo *II = Tok.getIdentifierInfo();
-  if (II == 0) return;  // Not an identifier.
-      
-  switch (II->getObjCKeywordID()) {
-    case tok::objc_class:
-	  ObjCParseClassDeclaration(atLoc);
-    case tok::objc_interface:
-	  ObjCParseInterfaceDeclaration();
-    case tok::objc_protocol:
-	  ObjCParseProtocolDeclaration();
-    case tok::objc_implementation:
-	  ObjCParseImplementationDeclaration();
-    case tok::objc_end:
-	  ObjCParseEndDeclaration();
-    case tok::objc_compatibility_alias:
-	  ObjCParseAliasDeclaration();
-	default:
-	  ; // TODO: need to issue a diagnostic...
+  switch (II ? II->getObjCKeywordID() : tok::objc_not_keyword) {
+  case tok::objc_class:
+    return ObjCParseAtClassDeclaration(AtLoc);
+  case tok::objc_interface:
+    return ObjCParseAtInterfaceDeclaration();
+  case tok::objc_protocol:
+    return ObjCParseAtProtocolDeclaration();
+  case tok::objc_implementation:
+    return ObjCParseAtImplementationDeclaration();
+  case tok::objc_end:
+    return ObjCParseAtEndDeclaration();
+  case tok::objc_compatibility_alias:
+    return ObjCParseAtAliasDeclaration();
+  default:
+    Diag(AtLoc, diag::err_unexpected_at);
+    SkipUntil(tok::semi);
   }
 }
 
@@ -481,7 +480,7 @@
 /// objc-class-declaration: 
 ///    @class identifier-list ;
 ///  
-void Parser::ObjCParseClassDeclaration(SourceLocation atLoc) {
+void Parser::ObjCParseAtClassDeclaration(SourceLocation atLoc) {
   ConsumeToken(); // the identifier "class"
   SmallVector<IdentifierInfo *, 8> classNames;
   
@@ -502,19 +501,26 @@
 	Actions.ParsedClassDeclaration(CurScope,&classNames[0],classNames.size());
   }
 }
-void Parser::ObjCParseInterfaceDeclaration() {
+void Parser::ObjCParseAtInterfaceDeclaration() {
+  assert(0 && "Unimp");
 }
-void Parser::ObjCParseProtocolDeclaration() {
+void Parser::ObjCParseAtProtocolDeclaration() {
+  assert(0 && "Unimp");
 }
-void Parser::ObjCParseImplementationDeclaration() {
+void Parser::ObjCParseAtImplementationDeclaration() {
+  assert(0 && "Unimp");
 }
-void Parser::ObjCParseEndDeclaration() {
+void Parser::ObjCParseAtEndDeclaration() {
+  assert(0 && "Unimp");
 }
-void Parser::ObjCParseAliasDeclaration() {
+void Parser::ObjCParseAtAliasDeclaration() {
+  assert(0 && "Unimp");
 }
 
 void Parser::ObjCParseInstanceMethodDeclaration() {
+  assert(0 && "Unimp");
 }
 
 void Parser::ObjCParseClassMethodDeclaration() {
+  assert(0 && "Unimp");
 }





More information about the cfe-commits mailing list