re PR c++/53096 ([DR 1333] [c++11] should be possible to default a copy ctor that...
authorPaolo Carlini <paolo.carlini@oracle.com>
Thu, 26 Apr 2012 23:32:14 +0000 (23:32 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 26 Apr 2012 23:32:14 +0000 (23:32 +0000)
/cp
2012-04-26  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/53096
* class.c (check_bases_and_members): Implement core/1333, do not
disallow defaulted in the class body non-const ref special members.

/testsuite
2012-04-26  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/53096
* g++.dg/cpp0x/defaulted35.C: New.
* g++.dg/cpp0x/defaulted15.C: Adjust.

From-SVN: r186888

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/defaulted15.C
gcc/testsuite/g++.dg/cpp0x/defaulted35.C [new file with mode: 0644]

index 86e44fc0fc62f452a06a61fa70502cb9e88157ee..db8bf7270e134f379234c65205d7b41ae1952f3c 100644 (file)
@@ -1,3 +1,9 @@
+2012-04-26  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/53096
+       * class.c (check_bases_and_members): Implement core/1333, do not
+       disallow defaulted in the class body non-const ref special members.
+
 2012-04-24  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/52363
index 7b6559c4231ca1e03063af0f20880d8c6163ab57..00aeefd5d48724518a4e306772fa30ba70055cbf 100644 (file)
@@ -1,6 +1,7 @@
 /* Functions related to building classes and their related objects.
    Copyright (C) 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
+   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011,
+   2012
    Free Software Foundation, Inc.
    Contributed by Michael Tiemann (tiemann@cygnus.com)
 
@@ -5144,9 +5145,6 @@ check_bases_and_members (tree t)
                 give the synthesis error.  */
              error ("%q+D declared to take const reference, but implicit "
                     "declaration would take non-const", fn);
-           else if (imp_const_p && !fn_const_p)
-             error ("%q+D declared to take non-const reference cannot be "
-                    "defaulted in the class body", fn);
          }
        defaulted_late_check (fn);
       }
index c7d000af88c019b4a744d46085bf2a78496552a0..576c4aa17f065b471f1ded0558879d33e8d46652 100644 (file)
@@ -1,3 +1,9 @@
+2012-04-26  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/53096
+       * g++.dg/cpp0x/defaulted35.C: New.
+       * g++.dg/cpp0x/defaulted15.C: Adjust.
+
 2012-04-26  Janis Johnson  <janisjo@codesourcery.com>
 
        * gcc.dg/bf-ms-layout.c: Adjust offsets to fit ms-bitfield
index 0a47c20f7786f4f543202521ff6034aa3eb78ece..6d182df2158237c46eb9e996bde367de233746f8 100644 (file)
@@ -43,7 +43,7 @@ SA(__has_trivial_copy(E));
 
 struct F
 {
-  F(F&) = default;             // { dg-error "non-const" }
+  F(F&) = default;
 };
 
 struct G: public F
diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted35.C b/gcc/testsuite/g++.dg/cpp0x/defaulted35.C
new file mode 100644 (file)
index 0000000..ca700fb
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/53096
+// { dg-options -std=c++0x }
+
+struct foo
+{
+  foo(foo&) = default;
+  foo& operator=(foo&) = default;
+};