diff mbox

C++ PATCH for c++/49066 (redeclaration of deleted fn)

Message ID 4DD7351B.80605@redhat.com
State New
Headers show

Commit Message

Jason Merrill May 21, 2011, 3:44 a.m. UTC
We need to propagate DECL_DELETED_FN in duplicate_decls.

Tested x86_64-pc-linux-gnu, applying to trunk and 4.6.
diff mbox

Patch

commit 62d3da092d1252e7e0534fe2220c11b2050013e4
Author: Jason Merrill <jason@redhat.com>
Date:   Fri May 20 18:05:46 2011 -0400

    	PR c++/49066
    	* decl.c (duplicate_decls): Preserve DECL_DELETED_FN.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 91df9ee..eae7d8e 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -1688,6 +1688,7 @@  duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
 	  error ("deleted definition of %qD", newdecl);
 	  error ("after previous declaration %q+D", olddecl);
 	}
+      DECL_DELETED_FN (newdecl) |= DECL_DELETED_FN (olddecl);
     }
 
   /* Deal with C++: must preserve virtual function table size.  */
diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted26.C b/gcc/testsuite/g++.dg/cpp0x/defaulted26.C
new file mode 100644
index 0000000..69bd0ac
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/defaulted26.C
@@ -0,0 +1,7 @@ 
+// PR c++/49066
+// { dg-options -std=c++0x }
+
+void foo() = delete;		// { dg-error "declared here" }
+void foo();
+
+int main() { foo(); }		// { dg-error "deleted" }