From: Fariborz Jahanian Date: Tue, 4 Sep 2007 19:26:51 +0000 (+0000) Subject: Patch to parse objective-c's @compatibility_alias directive. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e992af01d14e2e31037562c123af0a71ae1ed374;p=clang Patch to parse objective-c's @compatibility_alias directive. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41709 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Parse/ParseObjc.cpp b/Parse/ParseObjc.cpp index 624932ffe4..62149a040a 100644 --- a/Parse/ParseObjc.cpp +++ b/Parse/ParseObjc.cpp @@ -41,7 +41,7 @@ Parser::DeclTy *Parser::ParseObjCAtDirectives() { case tok::objc_end: return ParseObjCAtEndDeclaration(AtLoc); case tok::objc_compatibility_alias: - return ParseObjCAtAliasDeclaration(); + return ParseObjCAtAliasDeclaration(AtLoc); case tok::objc_synthesize: return ParseObjCPropertySynthesize(AtLoc); case tok::objc_dynamic: @@ -762,8 +762,26 @@ Parser::DeclTy *Parser::ParseObjCAtEndDeclaration(SourceLocation atLoc) { return 0; } -Parser::DeclTy *Parser::ParseObjCAtAliasDeclaration() { - assert(0 && "Unimp"); + +/// compatibility-alias-decl: +/// @compatibility_alias alias-name class-name ';' +/// +Parser::DeclTy *Parser::ParseObjCAtAliasDeclaration(SourceLocation atLoc) { + assert(Tok.isObjCAtKeyword(tok::objc_compatibility_alias) && + "ParseObjCAtAliasDeclaration(): Expected @compatibility_alias"); + ConsumeToken(); // consume compatibility_alias + if (Tok.getKind() != tok::identifier) { + Diag(Tok, diag::err_expected_ident); + return 0; + } + ConsumeToken(); // consume alias-name + if (Tok.getKind() != tok::identifier) { + Diag(Tok, diag::err_expected_ident); + return 0; + } + ConsumeToken(); // consume class-name; + if (Tok.getKind() != tok::semi) + Diag(Tok, diag::err_expected_semi_after, "@synthesize"); return 0; } diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index 76eab0d898..9d8021a24c 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -264,7 +264,7 @@ private: DeclTy *ParseObjCAtProtocolDeclaration(SourceLocation atLoc); DeclTy *ParseObjCAtImplementationDeclaration(SourceLocation atLoc); DeclTy *ParseObjCAtEndDeclaration(SourceLocation atLoc); - DeclTy *ParseObjCAtAliasDeclaration(); + DeclTy *ParseObjCAtAliasDeclaration(SourceLocation atLoc); DeclTy *ParseObjCPropertySynthesize(SourceLocation atLoc); DeclTy *ParseObjCPropertyDynamic(SourceLocation atLoc);