re PR c++/37906 (has_trivial_default_constructor vs. deleted copy ctor)
authorJason Merrill <jason@gcc.gnu.org>
Thu, 4 Dec 2008 19:00:03 +0000 (14:00 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 4 Dec 2008 19:00:03 +0000 (14:00 -0500)
        PR c++/37906
        * decl.c (grok_special_member_properties): Set TYPE_HAS_COMPLEX_DFLT
        here.
        * class.c (check_bases_and_members): Rather than assuming any
        user-declared default constructor is complex here.

From-SVN: r142442

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

index 029d2adbb86e43072ae163469eb7d4bee9658d98..9c74714b7bee2e6ed4962a7f9e4619adbc402d4e 100644 (file)
@@ -1,3 +1,11 @@
+2008-12-04  Jason Merrill  <jason@redhat.com>
+
+       PR c++/37906
+       * decl.c (grok_special_member_properties): Set TYPE_HAS_COMPLEX_DFLT
+       here.
+       * class.c (check_bases_and_members): Rather than assuming any
+       user-declared default constructor is complex here.
+
 2008-12-04  Richard Guenther  <rguenther@suse.de>
 
        PR c++/38334
        
 2008-11-05  Fabien Chene <fabien.chene@gmail.com>
 
-       PR c++/35219
+       PR c++/32519
        * cp-tree.h: Fix DECL_NONSTATIC_MEMBER_P to handle member template
        functions.
 
index 31123aa1ffd40c1aaf8647440bf069a4f4544d10..8553139979ab95f216debbec515cff8f578900cc 100644 (file)
@@ -4301,8 +4301,7 @@ check_bases_and_members (tree t)
     |= (CLASSTYPE_NON_AGGREGATE (t)
        || saved_nontrivial_dtor || saved_complex_asn_ref);
   TYPE_HAS_COMPLEX_ASSIGN_REF (t) |= TYPE_CONTAINS_VPTR_P (t);
-  TYPE_HAS_COMPLEX_DFLT (t)
-    |= (TYPE_HAS_DEFAULT_CONSTRUCTOR (t) || TYPE_CONTAINS_VPTR_P (t));
+  TYPE_HAS_COMPLEX_DFLT (t) |= TYPE_CONTAINS_VPTR_P (t);
 
   /* If the class has no user-declared constructor, but does have
      non-static const or reference data members that can never be
index f2e12b3c772a1ba857b4311b6bce8e13e6e95262..70ccd323f80798ae4a3fc09dd462350ed4a21df5 100644 (file)
@@ -9842,7 +9842,11 @@ grok_special_member_properties (tree decl)
            TYPE_HAS_CONST_INIT_REF (class_type) = 1;
        }
       else if (sufficient_parms_p (FUNCTION_FIRST_USER_PARMTYPE (decl)))
-       TYPE_HAS_DEFAULT_CONSTRUCTOR (class_type) = 1;
+       {
+         TYPE_HAS_DEFAULT_CONSTRUCTOR (class_type) = 1;
+         if (TREE_CODE (decl) == TEMPLATE_DECL || !DECL_DEFAULTED_FN (decl))
+           TYPE_HAS_COMPLEX_DFLT (class_type) = 1;
+       }
       else if (is_list_ctor (decl))
        TYPE_HAS_LIST_CTOR (class_type) = 1;
     }
index e58bdbb01b87a0b099a1002ccb0afe81ace2da2e..9c9d674083cfc8038de778e06b17fcecb4737e97 100644 (file)
@@ -1,3 +1,8 @@
+2008-12-04  Jason Merrill  <jason@redhat.com>
+
+       PR c++/37906
+       * g++.dg/cpp0x/defaulted6.C: New test.
+
 2008-12-04  Richard Guenther  <rguenther@suse.de>
 
        PR middle-end/36509
diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted6.C b/gcc/testsuite/g++.dg/cpp0x/defaulted6.C
new file mode 100644 (file)
index 0000000..c33d572
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/37906
+// { dg-options "-std=c++0x" }
+
+struct b
+{
+  b() = default;
+  b(const b&) = delete;
+};
+
+void test01()
+{
+  static_assert(__has_trivial_constructor(b), "default ctor not trivial");
+}