]> granicus.if.org Git - clang/commitdiff
Fixes/tweaks that prevent "defaults-i.m" from compiling.
authorSteve Naroff <snaroff@apple.com>
Sun, 16 Sep 2007 16:16:00 +0000 (16:16 +0000)
committerSteve Naroff <snaroff@apple.com>
Sun, 16 Sep 2007 16:16:00 +0000 (16:16 +0000)
- Allow classnames as the receiver (removing a FIXME from ParseObjCMessageExpression).
- Added a FIXME to ParseObjCMessageExpression()...we need to return a message expr AST node!

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

AST/Decl.cpp
Parse/ParseObjc.cpp
Sema/Sema.h
Sema/SemaDecl.cpp
Sema/SemaExpr.cpp
include/clang/AST/Decl.h

index 965ba2180a46b6dd5f7d2b70a29ba938b6cbea2b..4b464ee5e6e0e9480e7c2abe5ebe1c365d37c00c 100644 (file)
@@ -28,6 +28,42 @@ static unsigned nFieldDecls = 0;
 static unsigned nInterfaceDecls = 0;
 static bool StatSwitch = false;
 
+const char *Decl::getDeclKindName() {
+  switch (DeclKind) {
+  default: assert(0 && "Unknown decl kind!");
+  case Typedef:
+    return "Typedef";
+  case Function:
+    return "Function";
+  case BlockVariable:
+    return "BlockVariable";
+  case FileVariable:
+    return "FileVariable";
+  case ParmVariable:
+    return "ParmVariable";
+  case EnumConstant:
+    return "EnumConstant";
+  case ObjcInterface:
+    return "ObjcInterface";
+  case ObjcClass:
+    return "ObjcClass";
+  case ObjcMethod:
+    return "ObjcMethod";
+  case ObjcProtoMethod:
+    return "ObjcProtoMethod";
+  case ObjcProtocol:
+    return "ObjcProtocol";
+  case Struct:
+    return "Struct";
+  case Union:
+    return "Union";
+  case Class:
+    return "Class";
+  case Enum:
+    return "Enum";
+  }
+}
+
 bool Decl::CollectingStats(bool enable) {
   if (enable) StatSwitch = true;
        return StatSwitch;
index 8fa071a3fe8d28830e64cad01270cf2cb22e0131..e382974daf44ea6658ce4613e18ad8bf75df0fa1 100644 (file)
@@ -986,8 +986,11 @@ Parser::ExprResult Parser::ParseObjCMessageExpression() {
   assert(Tok.getKind() == tok::l_square && "'[' expected");
   SourceLocation Loc = ConsumeBracket(); // consume '['
   // Parse receiver
-  // FIXME: receiver as type-name/class-name
-  ParseAssignmentExpression();
+  if (Tok.getKind() == tok::identifier &&
+      Actions.isTypeName(*Tok.getIdentifierInfo(), CurScope))
+    ConsumeToken();
+  else
+    ParseAssignmentExpression();
   // Parse objc-selector
   IdentifierInfo *selIdent = ParseObjCSelector();
   if (Tok.getKind() == tok::colon) {
@@ -1024,7 +1027,7 @@ Parser::ExprResult Parser::ParseObjCMessageExpression() {
     return 0;
   }
   ConsumeBracket(); // consume ']'
-  return 0;
+  return 0; // FIXME: return a message expr AST!
 }
 
 Parser::ExprResult Parser::ParseObjCStringLiteral() {
index a6ce9cfbcfe0130e5a00f7e5494d05b3b48dff46..95086534b5839bf836bebda89cd5844333daa471 100644 (file)
@@ -182,7 +182,7 @@ private:
   ScopedDecl *LookupScopedDecl(IdentifierInfo *II, unsigned NSI, 
                                SourceLocation IdLoc, Scope *S);  
   ScopedDecl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, Scope *S);
-  Decl *ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II,
+  ScopedDecl *ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II,
                                  Scope *S);
   // Decl attributes - this routine is the top level dispatcher. 
   void HandleDeclAttributes(Decl *New, AttributeList *declspec_prefix,
index b792b525cc494417c66ea7ebc2b59b0fec41d9fb..16d72130f5a10e2dbec2a792d5d53d80fbc63eda 100644 (file)
@@ -815,8 +815,8 @@ Sema::DeclTy *Sema::ParseFunctionDefBody(DeclTy *D, StmtTy *Body) {
 
 /// ImplicitlyDefineFunction - An undeclared identifier was used in a function
 /// call, forming a call to an implicitly defined function (per C99 6.5.1p2).
-Decl *Sema::ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II,
-                                     Scope *S) {
+ScopedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc, 
+                                           IdentifierInfo &II, Scope *S) {
   if (getLangOptions().C99)  // Extension in C99.
     Diag(Loc, diag::ext_implicit_function_decl, II.getName());
   else  // Legal in C90, but warn about it.
@@ -842,7 +842,7 @@ Decl *Sema::ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II,
   while (S->getParent())
     S = S->getParent();
   
-  return static_cast<Decl*>(ActOnDeclarator(S, D, 0));
+  return dyn_cast<ScopedDecl>(static_cast<Decl*>(ActOnDeclarator(S, D, 0)));
 }
 
 
index b479c0a3ba35c3bb9ffd8dfcfbdd330282e42236..da1981f9a06d92bbd3d66a36ad73913e11082459 100644 (file)
@@ -60,7 +60,7 @@ Sema::ExprResult Sema::ActOnIdentifierExpr(Scope *S, SourceLocation Loc,
                                            IdentifierInfo &II,
                                            bool HasTrailingLParen) {
   // Could be enum-constant or decl.
-  Decl *D = LookupScopedDecl(&II, Decl::IDNS_Ordinary, Loc, S);
+  ScopedDecl *D = LookupScopedDecl(&II, Decl::IDNS_Ordinary, Loc, S);
   if (D == 0) {
     // Otherwise, this could be an implicitly declared function reference (legal
     // in C90, extension in C99).
index c47aec3596be31829ff9b0b6b1e2903f01549844..a920353ed917222df2a5c4aa11fb0196a3d88d55 100644 (file)
@@ -68,7 +68,8 @@ protected:
 public:
   
   Kind getKind() const { return DeclKind; }
-
+  const char *getDeclKindName();
+  
   /// setInvalidDecl - Indicates the Decl had a semantic error. This
   /// allows for graceful error recovery.
   void setInvalidDecl() { InvalidDecl = 1; }
@@ -83,6 +84,7 @@ public:
     case FileVariable:
     case ParmVariable:
     case EnumConstant:
+    case ObjcInterface:
       return IDNS_Ordinary;
     case Struct:
     case Union: