From: Steve Naroff Date: Mon, 11 Feb 2008 22:29:58 +0000 (+0000) Subject: Move Microsoft __declspec hack from the parser to the preprocessor. Since we have... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=705b5b532939740344d9a65cffc82f798d9332e6;p=clang Move Microsoft __declspec hack from the parser to the preprocessor. Since we have no plans to actually implement this construct, it is cleaner to limit the change to the preprocessor. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46973 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Lex/Preprocessor.cpp b/Lex/Preprocessor.cpp index 85a2c47c6c..a291fe35df 100644 --- a/Lex/Preprocessor.cpp +++ b/Lex/Preprocessor.cpp @@ -435,6 +435,7 @@ static void InitializePredefinedMacros(Preprocessor &PP, DefineBuiltinMacro(Buf, "__int16=short"); DefineBuiltinMacro(Buf, "__int32=int"); DefineBuiltinMacro(Buf, "__int64=long long"); + DefineBuiltinMacro(Buf, "__declspec(X)="); } // FIXME: Should emit a #line directive here. } diff --git a/Parse/ParseDecl.cpp b/Parse/ParseDecl.cpp index d6b92119c7..454a05dc44 100644 --- a/Parse/ParseDecl.cpp +++ b/Parse/ParseDecl.cpp @@ -36,48 +36,6 @@ Parser::TypeTy *Parser::ParseTypeName() { return Actions.ActOnTypeName(CurScope, DeclaratorInfo).Val; } -/// FuzzyParseMicrosoftDeclspec. The following construct is Microsoft's -/// equivalent of GCC's __attribute__. The grammar below is taken from -/// Microsoft's website. Unfortunately, it is incomplete. FIXME: If/when we -/// parse this for real, we will need to get a real/current grammar. -/// -/// decl-specifier: -/// '__declspec' '(' extended-decl-modifier-seq ')' -/// -/// extended-decl-modifier-seq: -/// extended-decl-modifier opt -/// extended-decl-modifier extended-decl-modifier-seq -/// -/// extended-decl-modifier: -/// align( # ) -/// allocate(" segname ") -/// appdomain -/// deprecated -/// dllimport -/// dllexport -/// jitintrinsic -/// naked -/// noalias -/// noinline -/// noreturn -/// nothrow -/// novtable -/// process -/// property({get=get_func_name|,put=put_func_name}) -/// restrict -/// selectany -/// thread -/// uuid(" ComObjectGUID ") -/// -void Parser::FuzzyParseMicrosoftDeclspec() { - assert(Tok.is(tok::kw___declspec) && "Not an declspec!"); - ConsumeToken(); - do { - ConsumeAnyToken(); - } while (ParenCount > 0 && Tok.isNot(tok::eof)); - return; -} - /// ParseAttributes - Parse a non-empty attributes list. /// /// [GNU] attributes: @@ -483,13 +441,6 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS) { case tok::kw_typedef: isInvalid = DS.SetStorageClassSpec(DeclSpec::SCS_typedef, Loc, PrevSpec); break; - case tok::kw___declspec: - FuzzyParseMicrosoftDeclspec(); - // Don't consume the next token, __declspec's can appear one after - // another. For example: - // __declspec(deprecated("comment1")) - // __declspec(deprecated("comment2")) extern unsigned int _winmajor; - continue; case tok::kw_extern: if (DS.isThreadSpecified()) Diag(Tok, diag::ext_thread_before, "extern"); @@ -674,9 +625,6 @@ void Parser::ParseStructUnionSpecifier(DeclSpec &DS) { Tok.is(tok::kw_union) ? DeclSpec::TST_union : DeclSpec::TST_struct; SourceLocation StartLoc = ConsumeToken(); - if (getLang().Microsoft && Tok.is(tok::kw___declspec)) - FuzzyParseMicrosoftDeclspec(); - // Parse the tag portion of this. DeclTy *TagDecl; if (ParseTag(TagDecl, TagType, StartLoc)) diff --git a/include/clang/Basic/TokenKinds.def b/include/clang/Basic/TokenKinds.def index d2fe914f82..a390f4d753 100644 --- a/include/clang/Basic/TokenKinds.def +++ b/include/clang/Basic/TokenKinds.def @@ -299,9 +299,6 @@ KEYWORD(__thread , EXTC90|EXTC99|EXTCPP|EXTCPP0x) // Apple Extension. KEYWORD(__private_extern__ , EXTC90|EXTC99|NOTCPP) -// Microsoft Extension. -KEYWORD(__declspec , EXTC90|EXTC99|NOTCPP) - // Alternate spelling for various tokens. There are GCC extensions in all // languages, but should not be disabled in strict conformance mode. ALIAS("__attribute__", __attribute) diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index 5a9eae03a5..907d7ac3ea 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -441,7 +441,6 @@ private: bool isTypeSpecifierQualifier() const; TypeTy *ParseTypeName(); - void FuzzyParseMicrosoftDeclspec(); AttributeList *ParseAttributes(); void ParseTypeofSpecifier(DeclSpec &DS);