Fix PR C++/48859
authorFabien Chêne <fabien@gcc.gnu.org>
Mon, 9 May 2011 17:42:21 +0000 (19:42 +0200)
committerFabien Chêne <fabien@gcc.gnu.org>
Mon, 9 May 2011 17:42:21 +0000 (19:42 +0200)
From-SVN: r173583

gcc/cp/ChangeLog
gcc/cp/init.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/init/pr48859.C [new file with mode: 0644]

index 4c4036ab3b9aecfaaa358f6bd549bb3f109b5d20..04096deee9cda8e0b5b948134c152e030e37eae4 100644 (file)
@@ -1,3 +1,9 @@
+2011-05-07  Fabien Chêne  <fabien@gcc.gnu.org>
+       
+       PR c++/48859
+       * init.c (diagnose_uninitialized_cst_or_ref_member_1): stop the
+       recursion if there is user defined constructor.
+
 2011-05-09  Jason Merrill  <jason@redhat.com>
 
        PR c++/34772
index 7a7379eca7e3e353c1ae89f95b5db81225805af4..3eb804dd56a4129d6667baa86477459bf16dd8fd 100644 (file)
@@ -1915,6 +1915,9 @@ diagnose_uninitialized_cst_or_ref_member_1 (tree type, tree origin,
 
       field_type = strip_array_types (TREE_TYPE (field));
 
+      if (type_has_user_provided_constructor (field_type))
+       continue;
+
       if (TREE_CODE (field_type) == REFERENCE_TYPE)
        {
          ++ error_count;
index b30addc7390937f09a3b354402fef0c360ba4444..04885cd76272b0e16011268481d5aca7c1147db9 100644 (file)
@@ -1,3 +1,7 @@
+2001-05-07  Fabien Chêne  <fabien@gcc.gnu.org>
+       PR c++/48859
+       * g++.dg/init/pr48859.C: New.
+
 2011-05-09  Jason Merrill  <jason@redhat.com>
 
        * gcc.dg/gcc.dg/uninit-D.c: Move to c-c++-common.
diff --git a/gcc/testsuite/g++.dg/init/pr48859.C b/gcc/testsuite/g++.dg/init/pr48859.C
new file mode 100644 (file)
index 0000000..8ef5c2e
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/48859
+// { dg-do compile }
+
+struct HasConstructor {
+  HasConstructor() {}
+};
+
+class ConstMember {
+  const HasConstructor empty_;
+};
+
+void foo() {
+  new ConstMember;
+}