summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/AST/Decl.cpp36
-rw-r--r--clang/Parse/ParseObjc.cpp9
-rw-r--r--clang/Sema/Sema.h2
-rw-r--r--clang/Sema/SemaDecl.cpp6
-rw-r--r--clang/Sema/SemaExpr.cpp2
-rw-r--r--clang/include/clang/AST/Decl.h4
6 files changed, 50 insertions, 9 deletions
diff --git a/clang/AST/Decl.cpp b/clang/AST/Decl.cpp
index 965ba2180a4..4b464ee5e6e 100644
--- a/clang/AST/Decl.cpp
+++ b/clang/AST/Decl.cpp
@@ -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;
diff --git a/clang/Parse/ParseObjc.cpp b/clang/Parse/ParseObjc.cpp
index 8fa071a3fe8..e382974daf4 100644
--- a/clang/Parse/ParseObjc.cpp
+++ b/clang/Parse/ParseObjc.cpp
@@ -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() {
diff --git a/clang/Sema/Sema.h b/clang/Sema/Sema.h
index a6ce9cfbcfe..95086534b58 100644
--- a/clang/Sema/Sema.h
+++ b/clang/Sema/Sema.h
@@ -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,
diff --git a/clang/Sema/SemaDecl.cpp b/clang/Sema/SemaDecl.cpp
index b792b525cc4..16d72130f5a 100644
--- a/clang/Sema/SemaDecl.cpp
+++ b/clang/Sema/SemaDecl.cpp
@@ -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)));
}
diff --git a/clang/Sema/SemaExpr.cpp b/clang/Sema/SemaExpr.cpp
index b479c0a3ba3..da1981f9a06 100644
--- a/clang/Sema/SemaExpr.cpp
+++ b/clang/Sema/SemaExpr.cpp
@@ -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).
diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index c47aec3596b..a920353ed91 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -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:
OpenPOWER on IntegriCloud