diff options
author | Steve Naroff <snaroff@apple.com> | 2008-12-25 14:16:32 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2008-12-25 14:16:32 +0000 |
commit | 44ac777741f74dccd630fd6d3af99bac461758a3 (patch) | |
tree | 8279f484ba75a73beb5d14399645ce270916c42f /clang/lib | |
parent | 4c1661102e98e926662391a6591e09128db60ee1 (diff) | |
download | bcm5719-llvm-44ac777741f74dccd630fd6d3af99bac461758a3.tar.gz bcm5719-llvm-44ac777741f74dccd630fd6d3af99bac461758a3.zip |
Add parser support for __cdecl, __stdcall, and __fastcall.
Change preprocessor implementation of _cdecl to reference __cdecl.
llvm-svn: 61430
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Lex/Preprocessor.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 36 |
2 files changed, 37 insertions, 3 deletions
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index 97ff07049f9..e68a44c188b 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -483,9 +483,7 @@ static void InitializePredefinedMacros(Preprocessor &PP, // Filter out some microsoft extensions when trying to parse in ms-compat // mode. if (PP.getLangOptions().Microsoft) { - DefineBuiltinMacro(Buf, "__stdcall="); - DefineBuiltinMacro(Buf, "__cdecl="); - DefineBuiltinMacro(Buf, "_cdecl="); + DefineBuiltinMacro(Buf, "_cdecl=__cdecl"); DefineBuiltinMacro(Buf, "__ptr64="); DefineBuiltinMacro(Buf, "__w64="); DefineBuiltinMacro(Buf, "__forceinline="); diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index a8052dc2904..bf75ab0e93e 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -560,6 +560,15 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, FuzzyParseMicrosoftDeclSpec(); continue; + // Microsoft single token adornments. + case tok::kw___cdecl: + case tok::kw___stdcall: + case tok::kw___fastcall: + if (!PP.getLangOptions().Microsoft) + goto DoneWithDeclSpec; + // Just ignore it. + break; + // storage-class-specifier case tok::kw_typedef: isInvalid = DS.SetStorageClassSpec(DeclSpec::SCS_typedef, Loc, PrevSpec); @@ -798,6 +807,11 @@ bool Parser::MaybeParseTypeSpecifier(DeclSpec &DS, int& isInvalid, ParseTypeofSpecifier(DS); return true; + case tok::kw___cdecl: + case tok::kw___stdcall: + case tok::kw___fastcall: + return PP.getLangOptions().Microsoft; + default: // Not a type-specifier; do nothing. return false; @@ -1199,6 +1213,11 @@ bool Parser::isTypeSpecifierQualifier() { // GNU ObjC bizarre protocol extension: <proto1,proto2> with implicit 'id'. case tok::less: return getLang().ObjC1; + + case tok::kw___cdecl: + case tok::kw___stdcall: + case tok::kw___fastcall: + return PP.getLangOptions().Microsoft; } } @@ -1268,6 +1287,11 @@ bool Parser::isDeclarationSpecifier() { // GNU ObjC bizarre protocol extension: <proto1,proto2> with implicit 'id'. case tok::less: return getLang().ObjC1; + + case tok::kw___cdecl: + case tok::kw___stdcall: + case tok::kw___fastcall: + return PP.getLangOptions().Microsoft; } } @@ -1298,6 +1322,13 @@ void Parser::ParseTypeQualifierListOpt(DeclSpec &DS, bool AttributesAllowed) { isInvalid = DS.SetTypeQual(DeclSpec::TQ_restrict, Loc, PrevSpec, getLang())*2; break; + case tok::kw___cdecl: + case tok::kw___stdcall: + case tok::kw___fastcall: + if (!PP.getLangOptions().Microsoft) + goto DoneWithTypeQuals; + // Just ignore it. + break; case tok::kw___attribute: if (AttributesAllowed) { DS.AddAttributes(ParseAttributes()); @@ -1305,6 +1336,7 @@ void Parser::ParseTypeQualifierListOpt(DeclSpec &DS, bool AttributesAllowed) { } // otherwise, FALL THROUGH! default: + DoneWithTypeQuals: // If this is not a type-qualifier token, we're done reading type // qualifiers. First verify that DeclSpec's are consistent. DS.Finish(Diags, PP.getSourceManager(), getLang()); @@ -1632,6 +1664,10 @@ void Parser::ParseParenDeclarator(Declarator &D) { // present even if the attribute list was empty. RequiresArg = true; } + // Eat any Microsoft extensions. + if ((Tok.is(tok::kw___cdecl) || Tok.is(tok::kw___stdcall) || + (Tok.is(tok::kw___fastcall))) && PP.getLangOptions().Microsoft) + ConsumeToken(); // If we haven't past the identifier yet (or where the identifier would be // stored, if this is an abstract declarator), then this is probably just |