================
@@ -0,0 +1,179 @@
+// RUN: %clang_cc1 -triple x86_64-win32 -fms-extensions -emit-llvm -o - %s | \
+// RUN:     FileCheck %s --check-prefixes=MSC --implicit-check-not=to_be_ 
--implicit-check-not=" dllexport"
+// RUN: %clang_cc1 -triple x86_64-mingw                 -emit-llvm -o - %s | \
+// RUN:     FileCheck %s --check-prefixes=GNU --implicit-check-not=to_be_ 
--implicit-check-not=" dllexport"
+// RUN: %clang_cc1 -triple x86_64-cygwin                -emit-llvm -o - %s | \
+// RUN:     FileCheck %s --check-prefixes=GNU --implicit-check-not=to_be_ 
--implicit-check-not=" dllexport"
+
+// Test that __declspec(dllexport) doesn't instantiate entities marked with
+// the exclude_from_explicit_instantiation attribute unless marked as 
dllexport explicitly.
+
+#define EXCLUDE_ATTR __attribute__((exclude_from_explicit_instantiation))
+
+struct NoAttrTag {};
+struct WithExportTag {};
+struct ImplicitTag {};
+
+template <class T>
+struct BasicCase {
+  // This will be instantiated explicitly as an exported function because it
+  // inherits dllexport from the class instantiation.
+  void to_be_exported();
+
+  // This will be instantiated implicitly as an exported function because it is
+  // marked as dllexport explicitly.
+  EXCLUDE_ATTR __declspec(dllexport) void to_be_memberwise_exported();
----------------
zmodem wrote:

Hmm, the rabbit hole goes deeper :-)

In my experience, dllimport/export attributes on members is much less common 
than putting it on classes, but we should of course strive to get the behavior 
right.

I'm not sure we want to /reject/ the combination of 
exclude_from_explicit_instantiation and dllimport/export on a member, but how 
about we drop (ignore) the dllimport/export attribute in that case (with a 
warning)?

That would be consistent with how we handle class-level dllimport/export: it 
gets ignored for methods with exclude_from_explicit_instantiation. And it fits 
with the intent of #40363.

https://github.com/llvm/llvm-project/pull/168171
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to