This repository was archived by the owner on Nov 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path0010-MSVC-Compatibility.patch
80 lines (77 loc) · 3.19 KB
/
0010-MSVC-Compatibility.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index cff8c76183f6..62b19871f93d 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -775,7 +775,9 @@ void Parser::ParseMicrosoftDeclSpecs(ParsedAttributes &Attrs,
void Parser::ParseMicrosoftTypeAttributes(ParsedAttributes &attrs) {
// Treat these like attributes
while (true) {
- switch (Tok.getKind()) {
+ // [MSVC Compatibility]
+ auto Kind = Tok.getKind();
+ switch (Kind) {
case tok::kw___fastcall:
case tok::kw___stdcall:
case tok::kw___thiscall:
@@ -791,6 +793,14 @@ void Parser::ParseMicrosoftTypeAttributes(ParsedAttributes &attrs) {
SourceLocation AttrNameLoc = ConsumeToken();
attrs.addNew(AttrName, AttrNameLoc, nullptr, AttrNameLoc, nullptr, 0,
ParsedAttr::AS_Keyword);
+ // [MSVC Compatibility]
+ if (Kind == tok::kw___stdcall || Kind == tok::kw___cdecl ||
+ Kind == tok::kw___fastcall || Kind == tok::kw___thiscall ||
+ Kind == tok::kw___regcall || Kind == tok::kw___vectorcall) {
+ if (Tok.is(tok::r_paren) && NextToken().is(tok::l_paren)) {
+ ConsumeParen();
+ }
+ }
break;
}
default:
@@ -3360,7 +3370,19 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
DS.SetRangeEnd(Tok.getAnnotationEndLoc());
ConsumeAnnotationToken(); // The typename
-
+ //[MSVC Compatibility]
+ if (Tok.is(tok::l_paren) &&
+ NextToken().isOneOf(tok::kw___stdcall, tok::kw___cdecl,
+ tok::kw___fastcall, tok::kw___thiscall,
+ tok::kw___regcall, tok::kw___vectorcall)) {
+ const Token &NextNextToken = PP.LookAhead(1);
+ if (NextNextToken.is(tok::r_paren)) {
+ const Token &NextToken2 = PP.LookAhead(2);
+ if (NextToken2.is(tok::l_paren)) {
+ ConsumeParen();
+ }
+ }
+ }
continue;
}
diff --git a/clang/lib/Parse/ParseTentative.cpp b/clang/lib/Parse/ParseTentative.cpp
index 512993a5278e..3ba75bf1277b 100644
--- a/clang/lib/Parse/ParseTentative.cpp
+++ b/clang/lib/Parse/ParseTentative.cpp
@@ -1642,8 +1642,23 @@ Parser::isCXXDeclarationSpecifier(Parser::TPResult BracedCastResult,
case tok::annot_decltype:
#define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
#include "clang/Basic/OpenCLImageTypes.def"
- if (NextToken().is(tok::l_paren))
+ if (NextToken().is(tok::l_paren)) {
+ //[MSVC Compatibility]
+ if (Tok.is(tok::annot_typename)) {
+ const Token &NextNextToken = PP.LookAhead(1);
+ if (NextNextToken.isOneOf(tok::kw___stdcall, tok::kw___cdecl,
+ tok::kw___fastcall, tok::kw___thiscall,
+ tok::kw___regcall, tok::kw___vectorcall)) {
+ const Token &NextToken2 = PP.LookAhead(2);
+ const Token &NextToken3 = PP.LookAhead(3);
+ if (NextToken2.is(tok::r_paren) && NextToken3.is(tok::l_paren)) {
+ return TPResult::True;
+ }
+ }
+ }
return TPResult::Ambiguous;
+ }
+
// This is a function-style cast in all cases we disambiguate other than
// one: