]> granicus.if.org Git - clang/commitdiff
Avoid redundant error when redefining a function as deleted.
authorDavid Blaikie <dblaikie@gmail.com>
Fri, 29 Jun 2012 18:00:25 +0000 (18:00 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Fri, 29 Jun 2012 18:00:25 +0000 (18:00 +0000)
Reviewed by Doug Gregor.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159442 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp
test/SemaCXX/deleted-function.cpp

index dab2d4de0925573bf6c960a185c0cdbffa0fb69b..babeaf7bd775ad6b22fa0c3aa4758e7927341faa 100644 (file)
@@ -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);
     }
index 2ee6064501963f0f80944c147cac5f85c04a9959..83764bafe8fe071b7e344b003b4c8d23c294249d 100644 (file)
@@ -63,3 +63,6 @@ template void test2<int>();
 template<typename> void test3() = delete; // expected-note {{explicit instantiation refers here}}
 template<typename> void test3();
 template void test3<int>(); // 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'}}