[PATCH] Allow dllimport/dllexport on inline functions and get the linkage right

Yunzhong Gao Yunzhong_Gao at playstation.sony.com
Wed May 14 23:22:34 PDT 2014


================
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2095
@@ -2094,1 +2094,3 @@
+def err_attribute_dllimport_function_definition : Error<
+  "dllimport cannot by applied to non-inline function definition">;
 def err_attribute_dllimport_data_definition : Error<
----------------
Typo. "cannot by applied" => "cannot be applied"

================
Comment at: lib/AST/ASTContext.cpp:7802
@@ +7801,3 @@
+static GVALinkage fixGVALinkageForDLLAttribute(GVALinkage L, const Decl *D) {
+  if (D->hasAttr<DLLImportAttr>()) {
+    if (L == GVA_DiscardableODR || L == GVA_StrongODR)
----------------
Reid Kleckner wrote:
> This should have a comment about the semantics of dllimport and dllexport, and link to the MSDN doc on dllexport with inline functions:
> http://msdn.microsoft.com/en-us/library/xa0d9ste.aspx
If the first argument to fixGVALinkageForDLLAttribute() is always the return result of
basicGVALinkageForFunction(), I wonder maybe it is more readable to just call the
basic linkage function from the fix linkage function.

Do we still check somewhere that we do not accept the combination of C99/GNU-inline with dllexport/dllimport?

================
Comment at: lib/Sema/SemaDecl.cpp:9774
@@ +9773,3 @@
+
+    if (!DA->isInherited() && !FD->isInlined()) {
+      Diag(FD->getLocation(), diag::err_attribute_dllimport_function_definition);
----------------
Do you have a test case for the isInherited() case where the dllimport definition should be allowed?

http://reviews.llvm.org/D3772






More information about the cfe-commits mailing list