aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Parse/ParseDecl.cpp4
-rw-r--r--lib/Parse/ParseDeclCXX.cpp26
-rw-r--r--lib/Parse/ParseTentative.cpp3
-rw-r--r--lib/Parse/Parser.cpp3
4 files changed, 36 insertions, 0 deletions
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index 3d29e9e702..e4c7569b61 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -3182,6 +3182,10 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
EllipsisLoc = ConsumeToken(); // Consume the ellipsis.
break;
}
+
+ // Skip any Microsoft attributes before a param.
+ if (getLang().Microsoft && Tok.is(tok::l_square))
+ ParseMicrosoftAttributes();
SourceLocation DSStart = Tok.getLocation();
diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp
index e1a97da9c2..c02f41a268 100644
--- a/lib/Parse/ParseDeclCXX.cpp
+++ b/lib/Parse/ParseDeclCXX.cpp
@@ -121,6 +121,8 @@ Decl *Parser::ParseNamespace(unsigned Context,
CXX0XAttributeList Attr;
if (getLang().CPlusPlus0x && isCXX0XAttributeSpecifier())
Attr = ParseCXX0XAttributes();
+ if (getLang().Microsoft && Tok.is(tok::l_square))
+ ParseMicrosoftAttributes();
ParseExternalDeclaration(Attr);
}
@@ -205,6 +207,8 @@ Decl *Parser::ParseLinkage(ParsingDeclSpec &DS,
if (getLang().CPlusPlus0x && isCXX0XAttributeSpecifier()) {
Attr = ParseCXX0XAttributes();
}
+ if (getLang().Microsoft && Tok.is(tok::l_square))
+ ParseMicrosoftAttributes();
if (Tok.isNot(tok::l_brace)) {
DS.setExternInLinkageSpec(true);
@@ -224,6 +228,8 @@ Decl *Parser::ParseLinkage(ParsingDeclSpec &DS,
CXX0XAttributeList Attr;
if (getLang().CPlusPlus0x && isCXX0XAttributeSpecifier())
Attr = ParseCXX0XAttributes();
+ if (getLang().Microsoft && Tok.is(tok::l_square))
+ ParseMicrosoftAttributes();
ParseExternalDeclaration(Attr);
}
@@ -1321,6 +1327,8 @@ void Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
// Optional C++0x attribute-specifier
if (getLang().CPlusPlus0x && isCXX0XAttributeSpecifier())
AttrList = ParseCXX0XAttributes();
+ if (getLang().Microsoft && Tok.is(tok::l_square))
+ ParseMicrosoftAttributes();
if (Tok.is(tok::kw_using)) {
// FIXME: Check for template aliases
@@ -2116,3 +2124,21 @@ ExprResult Parser::ParseCXX0XAlignArgument(SourceLocation Start) {
} else
return ParseConstantExpression();
}
+
+/// ParseMicrosoftAttributes - Parse a Microsoft attribute [Attr]
+///
+/// [MS] ms-attribute:
+/// '[' token-seq ']'
+///
+/// [MS] ms-attribute-seq:
+/// ms-attribute[opt]
+/// ms-attribute ms-attribute-seq
+void Parser::ParseMicrosoftAttributes() {
+ assert(Tok.is(tok::l_square) && "Not a Microsoft attribute list");
+
+ while (Tok.is(tok::l_square)) {
+ ConsumeBracket();
+ SkipUntil(tok::r_square, true, true);
+ ExpectAndConsume(tok::r_square, diag::err_expected_rsquare);
+ }
+}
diff --git a/lib/Parse/ParseTentative.cpp b/lib/Parse/ParseTentative.cpp
index 43d856d85f..731822ecdd 100644
--- a/lib/Parse/ParseTentative.cpp
+++ b/lib/Parse/ParseTentative.cpp
@@ -972,6 +972,9 @@ Parser::TPResult Parser::TryParseParameterDeclarationClause() {
return TPResult::True(); // '...' is a sign of a function declarator.
}
+ if (getLang().Microsoft && Tok.is(tok::l_square))
+ ParseMicrosoftAttributes();
+
// decl-specifier-seq
TPResult TPR = TryParseDeclarationSpecifier();
if (TPR != TPResult::Ambiguous())
diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp
index 8084088afc..13c25f478d 100644
--- a/lib/Parse/Parser.cpp
+++ b/lib/Parse/Parser.cpp
@@ -406,6 +406,9 @@ bool Parser::ParseTopLevelDecl(DeclGroupPtrTy &Result) {
CXX0XAttributeList Attr;
if (getLang().CPlusPlus0x && isCXX0XAttributeSpecifier())
Attr = ParseCXX0XAttributes();
+ if (getLang().Microsoft && Tok.is(tok::l_square))
+ ParseMicrosoftAttributes();
+
Result = ParseExternalDeclaration(Attr);
return false;
}