From: Aaron Ballman Date: Wed, 4 Dec 2013 23:23:19 +0000 (+0000) Subject: Giving a Subjects list to DllExport, which allows the removal of some custom semantic... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=11c616279561e7450cf7ea738dc0c64b33bdeba7;p=clang Giving a Subjects list to DllExport, which allows the removal of some custom semantic handling. The same cannot be done for DllImport, and so comments were left explaining why. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196429 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td index 3f42c2e154..c5f78985c7 100644 --- a/include/clang/Basic/Attr.td +++ b/include/clang/Basic/Attr.td @@ -1189,10 +1189,13 @@ def MsStruct : InheritableAttr { def DLLExport : InheritableAttr, TargetSpecificAttr { let Spellings = [Declspec<"dllexport">]; + let Subjects = SubjectList<[Function, Var]>; } def DLLImport : InheritableAttr, TargetSpecificAttr { let Spellings = [Declspec<"dllimport">]; + // Technically, the subjects for DllImport are Function and Var, but there is + // custom semantic handling required when MicrosoftExt is true. } def ForceInline : InheritableAttr { diff --git a/lib/Sema/TargetAttributesSema.cpp b/lib/Sema/TargetAttributesSema.cpp index 80168480ac..68f13494a3 100644 --- a/lib/Sema/TargetAttributesSema.cpp +++ b/lib/Sema/TargetAttributesSema.cpp @@ -201,17 +201,9 @@ DLLExportAttr *Sema::mergeDLLExportAttr(Decl *D, SourceRange Range, } static void HandleDLLExportAttr(Decl *D, const AttributeList &Attr, Sema &S) { - // Attribute can be applied only to functions or variables. - FunctionDecl *FD = dyn_cast(D); - if (!FD && !isa(D)) { - S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) - << Attr.getName() << 2 /*variable and function*/; - return; - } - // Currently, the dllexport attribute is ignored for inlined functions, unless // the -fkeep-inline-functions flag has been used. Warning is emitted; - if (FD && FD->isInlineSpecified()) { + if (isa(D) && cast(D)->isInlineSpecified()) { // FIXME: ... unless the -fkeep-inline-functions flag has been used. S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName(); return;