diff options
author | Steve Naroff <snaroff@apple.com> | 2008-12-24 20:59:21 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2008-12-24 20:59:21 +0000 |
commit | f59e17ecf06ac60065e2d02058bd6f21f5d216cc (patch) | |
tree | ffcf291e679d94109003422c3888a1a2ce9e83d0 /lib/Parse/ParseDecl.cpp | |
parent | 7a897224381564826c2894572df92fb5ddd9ea37 (diff) |
Add explicit "fuzzy" parse support for Microsoft declspec.
Remove previous __declspec macro that would effectively erase the construct prior to parsing.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61422 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseDecl.cpp')
-rw-r--r-- | lib/Parse/ParseDecl.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp index c7f92cf014..a8052dc290 100644 --- a/lib/Parse/ParseDecl.cpp +++ b/lib/Parse/ParseDecl.cpp @@ -192,6 +192,20 @@ AttributeList *Parser::ParseAttributes() { return CurrAttr; } +/// FuzzyParseMicrosoftDeclSpec. When -fms-extensions is enabled, this +/// routine is called to skip/ignore tokens that comprise the MS declspec. +void Parser::FuzzyParseMicrosoftDeclSpec() { + assert(Tok.is(tok::kw___declspec) && "Not a declspec!"); + ConsumeToken(); + if (Tok.is(tok::l_paren)) { + unsigned short savedParenCount = ParenCount; + do { + ConsumeAnyToken(); + } while (ParenCount > savedParenCount && Tok.isNot(tok::eof)); + } + return; +} + /// ParseDeclaration - Parse a full 'declaration', which consists of /// declaration-specifiers, some number of declarators, and a semicolon. /// 'Context' should be a Declarator::TheContext value. @@ -538,6 +552,13 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, case tok::kw___attribute: DS.AddAttributes(ParseAttributes()); continue; + + // Microsoft declspec support. + case tok::kw___declspec: + if (!PP.getLangOptions().Microsoft) + goto DoneWithDeclSpec; + FuzzyParseMicrosoftDeclSpec(); + continue; // storage-class-specifier case tok::kw_typedef: |