diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-10-06 21:41:19 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-10-06 21:41:19 +0000 |
commit | 77448b2fb40f56511145982f798c368f902bafeb (patch) | |
tree | 4963ba028981963fff09851c5561e64cc473b0b3 /gcc/cp | |
parent | 96f22277dec96894381ec19337dc1a20d5119dc8 (diff) | |
download | gcc-77448b2fb40f56511145982f798c368f902bafeb.tar.gz |
/cp
2013-10-06 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/58126
* class.c (check_bases): Propagate CLASSTYPE_READONLY_FIELDS_NEED_INIT
and CLASSTYPE_REF_FIELDS_NEED_INIT from bases to derived.
* init.c (diagnose_uninitialized_cst_or_ref_member_1): Extend error
messages about uninitialized const and references members to mention
the base class.
/testsuite
2013-10-06 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/58126
* g++.dg/init/uninitialized1.C: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@203232 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/cp/class.c | 6 | ||||
-rw-r--r-- | gcc/cp/init.c | 42 |
3 files changed, 49 insertions, 8 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6f6d8368116..fc2ec31c551 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,14 @@ 2013-10-06 Paolo Carlini <paolo.carlini@oracle.com> + PR c++/58126 + * class.c (check_bases): Propagate CLASSTYPE_READONLY_FIELDS_NEED_INIT + and CLASSTYPE_REF_FIELDS_NEED_INIT from bases to derived. + * init.c (diagnose_uninitialized_cst_or_ref_member_1): Extend error + messages about uninitialized const and references members to mention + the base class. + +2013-10-06 Paolo Carlini <paolo.carlini@oracle.com> + PR c++/56060 * pt.c (type_dependent_expression_p): Handle EXPR_PACK_EXPANSION. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 9e0229fcba3..c587e55ac68 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -1517,6 +1517,12 @@ check_bases (tree t, |= CLASSTYPE_CONTAINS_EMPTY_CLASS_P (basetype); TYPE_HAS_COMPLEX_DFLT (t) |= (!TYPE_HAS_DEFAULT_CONSTRUCTOR (basetype) || TYPE_HAS_COMPLEX_DFLT (basetype)); + SET_CLASSTYPE_READONLY_FIELDS_NEED_INIT + (t, CLASSTYPE_READONLY_FIELDS_NEED_INIT (t) + | CLASSTYPE_READONLY_FIELDS_NEED_INIT (basetype)); + SET_CLASSTYPE_REF_FIELDS_NEED_INIT + (t, CLASSTYPE_REF_FIELDS_NEED_INIT (t) + | CLASSTYPE_REF_FIELDS_NEED_INIT (basetype)); /* A standard-layout class is a class that: ... diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 70e7294c4d3..d18dc5e8deb 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -2120,11 +2120,24 @@ diagnose_uninitialized_cst_or_ref_member_1 (tree type, tree origin, ++ error_count; if (complain) { - if (using_new) - error ("uninitialized reference member in %q#T " - "using %<new%> without new-initializer", origin); + if (DECL_CONTEXT (field) == origin) + { + if (using_new) + error ("uninitialized reference member in %q#T " + "using %<new%> without new-initializer", origin); + else + error ("uninitialized reference member in %q#T", origin); + } else - error ("uninitialized reference member in %q#T", origin); + { + if (using_new) + error ("uninitialized reference member in base %q#T " + "of %q#T using %<new%> without new-initializer", + DECL_CONTEXT (field), origin); + else + error ("uninitialized reference member in base %q#T " + "of %q#T", DECL_CONTEXT (field), origin); + } inform (DECL_SOURCE_LOCATION (field), "%qD should be initialized", field); } @@ -2135,11 +2148,24 @@ diagnose_uninitialized_cst_or_ref_member_1 (tree type, tree origin, ++ error_count; if (complain) { - if (using_new) - error ("uninitialized const member in %q#T " - "using %<new%> without new-initializer", origin); + if (DECL_CONTEXT (field) == origin) + { + if (using_new) + error ("uninitialized const member in %q#T " + "using %<new%> without new-initializer", origin); + else + error ("uninitialized const member in %q#T", origin); + } else - error ("uninitialized const member in %q#T", origin); + { + if (using_new) + error ("uninitialized const member in base %q#T " + "of %q#T using %<new%> without new-initializer", + DECL_CONTEXT (field), origin); + else + error ("uninitialized const member in base %q#T " + "of %q#T", DECL_CONTEXT (field), origin); + } inform (DECL_SOURCE_LOCATION (field), "%qD should be initialized", field); } |