From: Fabien Chêne Date: Mon, 9 May 2011 17:42:21 +0000 (+0200) Subject: Fix PR C++/48859 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1c682d060b721d35ce3438e5d184a148e91599c9;p=gcc.git Fix PR C++/48859 From-SVN: r173583 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4c4036ab3b9..04096deee9c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2011-05-07 Fabien Chêne + + 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 PR c++/34772 diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 7a7379eca7e..3eb804dd56a 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b30addc7390..04885cd7627 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2001-05-07 Fabien Chêne + PR c++/48859 + * g++.dg/init/pr48859.C: New. + 2011-05-09 Jason Merrill * 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 index 00000000000..8ef5c2ee4a4 --- /dev/null +++ b/gcc/testsuite/g++.dg/init/pr48859.C @@ -0,0 +1,14 @@ +// PR c++/48859 +// { dg-do compile } + +struct HasConstructor { + HasConstructor() {} +}; + +class ConstMember { + const HasConstructor empty_; +}; + +void foo() { + new ConstMember; +}