diff options
author | Hans Wennborg <hans@hanshq.net> | 2014-08-24 00:12:36 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2014-08-24 00:12:36 +0000 |
commit | c2b7f7a6ab63755ee366bd4b2e334e895a8fc5ab (patch) | |
tree | 4eab11e51e03ef8e19b81f6b1bc69bca575e7dd2 /clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | |
parent | 584a70c820a543ad98288f3a184cae0c4f290bd0 (diff) | |
download | bcm5719-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/lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index 747eaf6d96f..c27a2430415 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -183,6 +183,14 @@ void Sema::InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs, continue; } + // Existing DLL attribute on the instantiation takes precedence. + if (TmplAttr->getKind() == attr::DLLExport || + TmplAttr->getKind() == attr::DLLImport) { + if (New->hasAttr<DLLExportAttr>() || New->hasAttr<DLLImportAttr>()) { + continue; + } + } + assert(!TmplAttr->isPackExpansion()); if (TmplAttr->isLateParsed() && LateAttrs) { // Late parsed attributes must be instantiated and attached after the |