summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/dllimport.cpp
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2014-08-24 00:12:36 +0000
committerHans Wennborg <hans@hanshq.net>2014-08-24 00:12:36 +0000
commitc2b7f7a6ab63755ee366bd4b2e334e895a8fc5ab (patch)
tree4eab11e51e03ef8e19b81f6b1bc69bca575e7dd2 /clang/test/CodeGenCXX/dllimport.cpp
parent584a70c820a543ad98288f3a184cae0c4f290bd0 (diff)
downloadbcm5719-llvm-c2b7f7a6ab63755ee366bd4b2e334e895a8fc5ab.tar.gz
bcm5719-llvm-c2b7f7a6ab63755ee366bd4b2e334e895a8fc5ab.zip
Don't assert on different DLL attributes in template and explicit instantiation (PR20137)
We would previously assert (a decl cannot have two DLL attributes) on this code: template <typename T> struct __declspec(dllimport) S { T f() { return T(); } }; template struct __declspec(dllexport) S<int>; The problem was that when instantiating, we would take the attribute from the template even if the instantiation itself already had an attribute. Also, don't inherit DLL attributes from the template to its members before instantiation, as the attribute may change. I couldn't figure out what MinGW does here, so I'm leaving that open. At least we're not asserting anymore. llvm-svn: 216340
Diffstat (limited to 'clang/test/CodeGenCXX/dllimport.cpp')
-rw-r--r--clang/test/CodeGenCXX/dllimport.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/dllimport.cpp b/clang/test/CodeGenCXX/dllimport.cpp
index 3292a9fa38a..3ba7f963823 100644
--- a/clang/test/CodeGenCXX/dllimport.cpp
+++ b/clang/test/CodeGenCXX/dllimport.cpp
@@ -693,6 +693,12 @@ USEMEMFUNC(PartiallySpecializedImportedClassTemplate<void*>, f);
// M32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc void @"\01?f@?$PartiallySpecializedImportedClassTemplate@PAX@@QAEXXZ"
// G32-DAG: define linkonce_odr x86_thiscallcc void @_ZN41PartiallySpecializedImportedClassTemplateIPvE1fEv
+// Attributes on the instantiation take precedence over attributes on the template.
+template <typename T> struct __declspec(dllexport) ExplicitlyInstantiatedWithDifferentAttr { void f() {} };
+template struct __declspec(dllimport) ExplicitlyInstantiatedWithDifferentAttr<int>;
+USEMEMFUNC(ExplicitlyInstantiatedWithDifferentAttr<int>, f);
+// M32-DAG: {{declare|define available_externally}} dllimport x86_thiscallcc void @"\01?f@?$ExplicitlyInstantiatedWithDifferentAttr@H@@QAEXXZ"
+
//===----------------------------------------------------------------------===//
// Classes with template base classes
OpenPOWER on IntegriCloud