diff options
| author | Francois Pichet <pichet2000@gmail.com> | 2011-05-11 02:14:46 +0000 |
|---|---|---|
| committer | Francois Pichet <pichet2000@gmail.com> | 2011-05-11 02:14:46 +0000 |
| commit | 3abc9b8b7990e3e6ea4623dbed3991aac7b1601c (patch) | |
| tree | d57daa9e7b9efe1ed7c401ea5809d0e62bbb35d1 /clang/lib/Parse | |
| parent | 50117f81862fa1f6c5f50db9ca32ac8fa2776255 (diff) | |
| download | bcm5719-llvm-3abc9b8b7990e3e6ea4623dbed3991aac7b1601c.tar.gz bcm5719-llvm-3abc9b8b7990e3e6ea4623dbed3991aac7b1601c.zip | |
In Microsoft mode, allow pure specifier (=0) on inline functions declared at class scope.
This removes 2 errors when parsing MFC code with clang
Example:
class A {
virtual void f() = 0 { }
}
llvm-svn: 131175
Diffstat (limited to 'clang/lib/Parse')
| -rw-r--r-- | clang/lib/Parse/ParseCXXInlineMethods.cpp | 5 | ||||
| -rw-r--r-- | clang/lib/Parse/ParseDeclCXX.cpp | 15 |
2 files changed, 16 insertions, 4 deletions
diff --git a/clang/lib/Parse/ParseCXXInlineMethods.cpp b/clang/lib/Parse/ParseCXXInlineMethods.cpp index 87e2f343748..1e1a0e2b070 100644 --- a/clang/lib/Parse/ParseCXXInlineMethods.cpp +++ b/clang/lib/Parse/ParseCXXInlineMethods.cpp @@ -23,7 +23,7 @@ using namespace clang; /// and store its tokens for parsing after the C++ class is complete. Decl *Parser::ParseCXXInlineMethodDef(AccessSpecifier AS, ParsingDeclarator &D, const ParsedTemplateInfo &TemplateInfo, - const VirtSpecifiers& VS) { + const VirtSpecifiers& VS, ExprResult& Init) { assert(D.isFunctionDeclarator() && "This isn't a function declarator!"); assert((Tok.is(tok::l_brace) || Tok.is(tok::colon) || Tok.is(tok::kw_try)) && "Current token not a '{', ':' or 'try'!"); @@ -40,7 +40,8 @@ Decl *Parser::ParseCXXInlineMethodDef(AccessSpecifier AS, ParsingDeclarator &D, else { // FIXME: pass template information through FnD = Actions.ActOnCXXMemberDeclarator(getCurScope(), AS, D, move(TemplateParams), 0, - VS, 0, /*IsDefinition*/true); + VS, Init.release(), + /*IsDefinition*/true); } HandleMemberFunctionDefaultArgs(D, FnD); diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp index ccc245016e4..ecf66a79dba 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -1581,6 +1581,7 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, ParsingDeclarator DeclaratorInfo(*this, DS, Declarator::MemberContext); VirtSpecifiers VS; + ExprResult Init; if (Tok.isNot(tok::colon)) { // Don't parse FOO:BAR as if it were a typo for FOO::BAR. @@ -1602,6 +1603,17 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, // If attributes exist after the declarator, but before an '{', parse them. MaybeParseGNUAttributes(DeclaratorInfo); + // MSVC permits pure specifier on inline functions declared at class scope. + // Hence check for =0 before checking for function definition. + if (getLang().Microsoft && Tok.is(tok::equal) && + DeclaratorInfo.isFunctionDeclarator() && + NextToken().is(tok::numeric_constant)) { + ConsumeToken(); + Init = ParseInitializer(); + if (Init.isInvalid()) + SkipUntil(tok::comma, true, true); + } + // function-definition: if (Tok.is(tok::l_brace) || (DeclaratorInfo.isFunctionDeclarator() && @@ -1631,7 +1643,7 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, return; } - ParseCXXInlineMethodDef(AS, DeclaratorInfo, TemplateInfo, VS); + ParseCXXInlineMethodDef(AS, DeclaratorInfo, TemplateInfo, VS, Init); // Consume the optional ';' if (Tok.is(tok::semi)) ConsumeToken(); @@ -1646,7 +1658,6 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS, llvm::SmallVector<Decl *, 8> DeclsInGroup; ExprResult BitfieldSize; - ExprResult Init; bool Deleted = false; SourceLocation DefaultLoc; |

