From 8361337727f7909ff99c9bf64f96abc249ad1512 Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 30 Apr 2010 04:23:00 +0000 Subject: [PATCH 1/1] PR c++/43890 * init.c (diagnose_uninitialized_cst_or_ref_member): check for user-provided constructor while recursing. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158918 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/init.c | 21 ++++++++++++--------- gcc/testsuite/ChangeLog | 6 ++++++ 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index de656778c19..1d9dd43bc65 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2010-04-29 Fabien Chêne + + PR c++/43890 + * init.c (diagnose_uninitialized_cst_or_ref_member): check for + user-provided constructor while recursing. + 2010-04-28 Manuel López-Ibáñez PR c++/9335 diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 5f0f665afe4..70e3d387e9e 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -1779,6 +1779,9 @@ diagnose_uninitialized_cst_or_ref_member_1 (tree type, tree origin, { tree field; + if (type_has_user_provided_constructor (type)) + return; + for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field)) { tree field_type; @@ -1791,8 +1794,8 @@ diagnose_uninitialized_cst_or_ref_member_1 (tree type, tree origin, if (TREE_CODE (field_type) == REFERENCE_TYPE) { if (using_new) - error ("uninitialized reference member in %q#T using %", - origin); + error ("uninitialized reference member in %q#T " + "using % without new-initializer", origin); else error ("uninitialized reference member in %q#T", origin); inform (DECL_SOURCE_LOCATION (field), @@ -1802,8 +1805,8 @@ diagnose_uninitialized_cst_or_ref_member_1 (tree type, tree origin, if (CP_TYPE_CONST_P (field_type)) { if (using_new) - error ("uninitialized const member in %q#T using %", - origin); + error ("uninitialized const member in %q#T " + "using % without new-initializer", origin); else error ("uninitialized const member in %q#T", origin); inform (DECL_SOURCE_LOCATION (field), @@ -1908,13 +1911,13 @@ build_new_1 (VEC(tree,gc) **placement, tree type, tree nelts, is_initialized = (TYPE_NEEDS_CONSTRUCTING (elt_type) || *init != NULL); - if (*init == NULL && !type_has_user_provided_constructor (elt_type)) + if (*init == NULL) { - bool uninitialized_error = false; + bool maybe_uninitialized_error = false; /* A program that calls for default-initialization [...] of an entity of reference type is ill-formed. */ if (CLASSTYPE_REF_FIELDS_NEED_INIT (elt_type)) - uninitialized_error = true; + maybe_uninitialized_error = true; /* A new-expression that creates an object of type T initializes that object as follows: @@ -1929,9 +1932,9 @@ build_new_1 (VEC(tree,gc) **placement, tree type, tree nelts, const-qualified type, the program is ill-formed; */ if (CLASSTYPE_READONLY_FIELDS_NEED_INIT (elt_type)) - uninitialized_error = true; + maybe_uninitialized_error = true; - if (uninitialized_error) + if (maybe_uninitialized_error) { if (complain & tf_error) diagnose_uninitialized_cst_or_ref_member (elt_type, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f6527d55e0c..b2b0e5137b2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2010-04-29 Fabien Chêne + + PR c++/43890 + * init.c (diagnose_uninitialized_cst_or_ref_member): check for + user-provided constructor while recursing. + 2010-04-29 Janus Weil PR fortran/42274 -- 2.11.0