diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2013-12-04 23:23:19 +0000 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2013-12-04 23:23:19 +0000 |
commit | 8b9e236bb4d2db3ebaaa94047d0da1f1485614f5 (patch) | |
tree | 7e349f99737f32e1152bc30a2ff9225fcc49e2e3 | |
parent | aad23ecadb78a6c57719765817276746c23bd3ff (diff) | |
download | bcm5719-llvm-8b9e236bb4d2db3ebaaa94047d0da1f1485614f5.tar.gz bcm5719-llvm-8b9e236bb4d2db3ebaaa94047d0da1f1485614f5.zip |
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.
llvm-svn: 196429
-rw-r--r-- | clang/include/clang/Basic/Attr.td | 3 | ||||
-rw-r--r-- | clang/lib/Sema/TargetAttributesSema.cpp | 10 |
2 files changed, 4 insertions, 9 deletions
diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 3f42c2e154e..c5f78985c79 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/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/clang/lib/Sema/TargetAttributesSema.cpp b/clang/lib/Sema/TargetAttributesSema.cpp index 80168480ac7..68f13494a3e 100644 --- a/clang/lib/Sema/TargetAttributesSema.cpp +++ b/clang/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<FunctionDecl>(D); - if (!FD && !isa<VarDecl>(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<FunctionDecl>(D) && cast<FunctionDecl>(D)->isInlineSpecified()) { // FIXME: ... unless the -fkeep-inline-functions flag has been used. S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName(); return; |