From 34655c9e682dcc87387798714a8ad812a0427299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabien=20Ch=C3=AAne?= Date: Mon, 10 May 2010 18:37:45 +0000 Subject: re PR c++/43719 (uninitialized const member incorrectly accepted, using an array) PR c++/43719 * decl.c (check_initializer): strip array type before checking for uninitialized const or ref members. From-SVN: r159242 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/decl.c | 13 ++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'gcc/cp') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d41a95f..c62f817 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2010-05-10 Fabien ChĂȘne + + PR c++/43719 + * decl.c (check_initializer): strip array type before checking for + uninitialized const or ref members. + 2010-05-07 Fabien ChĂȘne PR c++/43951 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 70b1041..4aa3441 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -5207,6 +5207,7 @@ check_initializer (tree decl, tree init, int flags, tree *cleanup) { tree type = TREE_TYPE (decl); tree init_code = NULL; + tree core_type; /* Things that are going to be initialized need to have complete type. */ @@ -5318,14 +5319,12 @@ check_initializer (tree decl, tree init, int flags, tree *cleanup) check_for_uninitialized_const_var (decl); return build_aggr_init_full_exprs (decl, init, flags); } - else if (MAYBE_CLASS_TYPE_P (type)) + else if (MAYBE_CLASS_TYPE_P (core_type = strip_array_types (type))) { - tree core_type = strip_array_types (type); - - if (CLASSTYPE_READONLY_FIELDS_NEED_INIT (core_type)) - error ("structure %qD with uninitialized const members", decl); - if (CLASSTYPE_REF_FIELDS_NEED_INIT (core_type)) - error ("structure %qD with uninitialized reference members", decl); + if (CLASSTYPE_READONLY_FIELDS_NEED_INIT (core_type) + || CLASSTYPE_REF_FIELDS_NEED_INIT (core_type)) + diagnose_uninitialized_cst_or_ref_member (core_type, /*using_new=*/false, + /*complain=*/true); check_for_uninitialized_const_var (decl); } -- cgit v1.1