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/ParseDeclCXX.cpp | |
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/ParseDeclCXX.cpp')
-rw-r--r-- | clang/lib/Parse/ParseDeclCXX.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
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; |