// Apple Extension.
KEYWORD(__private_extern__ , EXTC90|EXTC99|NOTCPP)
+// Microsoft Extension.
+KEYWORD(__declspec , EXTC90|EXTC99|EXTCPP|EXTCPP0x)
+
// Alternate spelling for various tokens. There are GCC extensions in all
// languages, but should not be disabled in strict conformance mode.
ALIAS("__attribute__", __attribute)
TypeTy *ParseTypeName();
AttributeList *ParseAttributes();
+ void FuzzyParseMicrosoftDeclSpec();
void ParseTypeofSpecifier(DeclSpec &DS);
/// DeclaratorScopeObj - RAII object used in Parser::ParseDirectDeclarator to
DefineBuiltinMacro(Buf, "__int16=short");
DefineBuiltinMacro(Buf, "__int32=int");
DefineBuiltinMacro(Buf, "__int64=long long");
- DefineBuiltinMacro(Buf, "__declspec(X)=");
}
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.
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:
if (Tok.is(tok::kw___attribute))
Attr = ParseAttributes();
+ // If declspecs exist after tag, parse them.
+ if (Tok.is(tok::kw___declspec) && PP.getLangOptions().Microsoft)
+ FuzzyParseMicrosoftDeclSpec();
+
// Parse the (optional) nested-name-specifier.
CXXScopeSpec SS;
if (getLang().CPlusPlus && MaybeParseCXXScopeSpecifier(SS)) {