[cfe-commits] r159442 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/SemaCXX/deleted-function.cpp

David Blaikie dblaikie at gmail.com
Fri Jun 29 11:00:25 PDT 2012


Author: dblaikie
Date: Fri Jun 29 13:00:25 2012
New Revision: 159442

URL: http://llvm.org/viewvc/llvm-project?rev=159442&view=rev
Log:
Avoid redundant error when redefining a function as deleted.

Reviewed by Doug Gregor.

Modified:
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
    cfe/trunk/test/SemaCXX/deleted-function.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=159442&r1=159441&r2=159442&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Jun 29 13:00:25 2012
@@ -10318,8 +10318,8 @@
   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);
     }

Modified: cfe/trunk/test/SemaCXX/deleted-function.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/deleted-function.cpp?rev=159442&r1=159441&r2=159442&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/deleted-function.cpp (original)
+++ cfe/trunk/test/SemaCXX/deleted-function.cpp Fri Jun 29 13:00:25 2012
@@ -63,3 +63,6 @@
 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'}}





More information about the cfe-commits mailing list