r210550 - Don't inherit dll attributes to deleted methods (PR19988)
Hans Wennborg
hans at hanshq.net
Tue Jun 10 10:53:23 PDT 2014
Author: hans
Date: Tue Jun 10 12:53:23 2014
New Revision: 210550
URL: http://llvm.org/viewvc/llvm-project?rev=210550&view=rev
Log:
Don't inherit dll attributes to deleted methods (PR19988)
We would previously end up with an error when instantiating the
following template:
template <typename> struct __declspec(dllimport) S {
void foo() = delete;
};
S<int> s;
error: attribute 'dllimport' cannot be applied to a deleted function
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/dllimport.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=210550&r1=210549&r2=210550&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Jun 10 12:53:23 2014
@@ -4379,6 +4379,8 @@ static void checkDLLAttribute(Sema &S, C
for (Decl *Member : Class->decls()) {
if (!isa<CXXMethodDecl>(Member) && !isa<VarDecl>(Member))
continue;
+ if (isa<CXXMethodDecl>(Member) && cast<CXXMethodDecl>(Member)->isDeleted())
+ continue;
if (InheritableAttr *MemberAttr = getDLLAttr(Member)) {
if (S.Context.getTargetInfo().getCXXABI().isMicrosoft() &&
@@ -4399,9 +4401,6 @@ static void checkDLLAttribute(Sema &S, C
if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(Member)) {
if (ClassExported) {
- if (MD->isDeleted())
- continue;
-
if (MD->isUserProvided()) {
// Instantiate non-default methods.
S.MarkFunctionReferenced(Class->getLocation(), MD);
Modified: cfe/trunk/test/SemaCXX/dllimport.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/dllimport.cpp?rev=210550&r1=210549&r2=210550&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/dllimport.cpp (original)
+++ cfe/trunk/test/SemaCXX/dllimport.cpp Tue Jun 10 12:53:23 2014
@@ -983,3 +983,11 @@ template <typename T> int S<T>::x = size
template <> struct __declspec(dllimport) S<int> { static int x; }; // expected-note{{attribute is here}}
int S<int>::x = -1; // expected-error{{definition of dllimport static field not allowed}}
}
+
+namespace PR19988 {
+// Don't error about applying delete to dllimport member function when instantiating.
+template <typename> struct __declspec(dllimport) S {
+ void foo() = delete;
+};
+S<int> s;
+}
More information about the cfe-commits
mailing list