diff options
author | Fabien Chêne <fabien.chene@gmail.com> | 2010-05-10 18:37:45 +0000 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2010-05-10 14:37:45 -0400 |
commit | 34655c9e682dcc87387798714a8ad812a0427299 (patch) | |
tree | 99bfd917483d7c8ebb3eadf53457cb4020d453a2 /gcc/cp | |
parent | 1de12eab7496fe7a8a03e83efbbf6dd6318c3aa0 (diff) | |
download | gcc-34655c9e682dcc87387798714a8ad812a0427299.zip gcc-34655c9e682dcc87387798714a8ad812a0427299.tar.gz gcc-34655c9e682dcc87387798714a8ad812a0427299.tar.bz2 |
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
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/decl.c | 13 |
2 files changed, 12 insertions, 7 deletions
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 <fabien.chene@gmail.com> + + PR c++/43719 + * decl.c (check_initializer): strip array type before checking for + uninitialized const or ref members. + 2010-05-07 Fabien Chêne <fabien.chene@gmail.com> 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); } |