This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Implements the new wording drafted for FI-4/5.

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);



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]