Patchwork C++: Remove restrictions on defaulting non-public or explicit special member functions on their first declaration

login
register
mail settings
Submitter ville
Date Nov. 12, 2010, 10:52 p.m.
Message ID <1289602360.6612.1.camel@ville-hp>
Download mbox | patch
Permalink /patch/71027/
State New
Headers show

Comments

ville - Nov. 12, 2010, 10:52 p.m.
Implements the new wording drafted for FI-4/5.
ville - Nov. 12, 2010, 10:56 p.m.
On 13 November 2010 00:52, ville <ville.voutilainen@gmail.com> wrote:
> Implements the new wording drafted for FI-4/5.

Argh, that should've been FI-1/2, my bad.

Patch

Index: gcc/ChangeLog
===================================================================
--- gcc/ChangeLog	(revision 166633)
+++ gcc/ChangeLog	(working copy)
@@ -1,3 +1,9 @@ 
+2010-11-13  Ville Voutilainen <ville.voutilainen@gmail.com> <ville.voutilainen@symbio.com>
+
+	* method.c (defaultable_fn_check): Do not disallow defaulting a
+	non-public or explicit special member function on its first
+	declaration.
+
 2010-11-11  Jan Hubicka  <jh@suse.cz>
 
 	* opts.c (finish_options): Do not error on -flto-partition alone.
Index: gcc/testsuite/g++.dg/cpp0x/defaulted15.C
===================================================================
--- gcc/testsuite/g++.dg/cpp0x/defaulted15.C	(revision 166633)
+++ gcc/testsuite/g++.dg/cpp0x/defaulted15.C	(working copy)
@@ -11,24 +11,24 @@ 
 struct B
 {
 private:
-  B() = default;		// { dg-error "access" }
+  B() = default;
 };
 
 struct C
 {
 protected:
-  ~C() = default;		// { dg-error "access" }
+  ~C() = default;
 };
 
 struct D
 {
 private:
-  D& operator= (const D&) = default; // { dg-error "access" }
+  D& operator= (const D&) = default;
 };
 
 struct E
 {
-  explicit E (const E&) = default; // { dg-error "explicit" }
+  explicit E (const E&) = default;
 };
 
 struct F
Index: gcc/cp/method.c
===================================================================
--- gcc/cp/method.c	(revision 166633)
+++ gcc/cp/method.c	(working copy)
@@ -1628,12 +1628,6 @@ 
 	  }
       if (TYPE_BEING_DEFINED (DECL_CONTEXT (fn)))
 	{
-	  if (DECL_NONCONVERTING_P (fn))
-	    error ("%qD declared explicit cannot be defaulted in the class "
-		   "body", fn);
-	  if (current_access_specifier != access_public_node)
-	    error ("%qD declared with non-public access cannot be defaulted "
-		   "in the class body", fn);
 	  if (TYPE_RAISES_EXCEPTIONS (TREE_TYPE (fn)))
 	    error ("function %q+D defaulted on its first declaration "
 		   "must not have an exception-specification", fn);