From: David Blaikie Date: Fri, 29 Jun 2012 18:00:25 +0000 (+0000) Subject: Avoid redundant error when redefining a function as deleted. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=619ee6acdd43b95b20c5aa96b22c3f238ce1a021;p=clang Avoid redundant error when redefining a function as deleted. Reviewed by Doug Gregor. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159442 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index dab2d4de09..babeaf7bd7 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -10318,8 +10318,8 @@ void Sema::SetDeclDeleted(Decl *Dcl, SourceLocation DelLoc) { if (const FunctionDecl *Prev = Fn->getPreviousDecl()) { // Don't consider the implicit declaration we generate for explicit // specializations. FIXME: Do not generate these implicit declarations. - if (Prev->getTemplateSpecializationKind() != TSK_ExplicitSpecialization - || Prev->getPreviousDecl()) { + if ((Prev->getTemplateSpecializationKind() != TSK_ExplicitSpecialization + || Prev->getPreviousDecl()) && !Prev->isDefined()) { Diag(DelLoc, diag::err_deleted_decl_not_first); Diag(Prev->getLocation(), diag::note_previous_declaration); } diff --git a/test/SemaCXX/deleted-function.cpp b/test/SemaCXX/deleted-function.cpp index 2ee6064501..83764bafe8 100644 --- a/test/SemaCXX/deleted-function.cpp +++ b/test/SemaCXX/deleted-function.cpp @@ -63,3 +63,6 @@ template void test2(); template void test3() = delete; // expected-note {{explicit instantiation refers here}} template void test3(); template void test3(); // expected-error {{explicit instantiation of undefined function template 'test3'}} + +void test4() {} // expected-note {{previous definition is here}} +void test4() = delete; // expected-error {{redefinition of 'test4'}}