Commit 0df9da03 by Fabien Chêne

init.c (perform_member_init): Homogenize uninitialized diagnostics.

2014-04-01  Fabien Chêne  <fabien@gcc.gnu.org>

	* cp/init.c (perform_member_init): Homogenize uninitialized
	diagnostics.

2014-04-01  Fabien Chêne  <fabien@gcc.gnu.org>

        * g++.dg/init/ctor4.C: Adjust.
	* g++.dg/init/ctor4-1.C: New.
	* g++.dg/cpp0x/defaulted2.C: Adjust.

From-SVN: r208998
parent 24991604
2014-04-01 Fabien Chêne <fabien@gcc.gnu.org>
* cp/init.c (perform_member_init): Homogenize uninitialized
diagnostics.
2014-04-01 Jason Merrill <jason@redhat.com> 2014-04-01 Jason Merrill <jason@redhat.com>
PR c++/60708 PR c++/60708
...@@ -44,9 +49,9 @@ ...@@ -44,9 +49,9 @@
2014-03-26 Fabien Chêne <fabien@gcc.gnu.org> 2014-03-26 Fabien Chêne <fabien@gcc.gnu.org>
PR c++/52369 PR c++/52369
* cp/method.c (walk_field_subobs): improve the diagnostic * cp/method.c (walk_field_subobs): Improve the diagnostic
locations for both REFERENCE_TYPEs and non-static const members. locations for both REFERENCE_TYPEs and non-static const members.
* cp/init.c (diagnose_uninitialized_cst_or_ref_member): use %q#D * cp/init.c (diagnose_uninitialized_cst_or_ref_member): Use %q#D
instead of %qD to be consistent with the c++11 diagnostic. instead of %qD to be consistent with the c++11 diagnostic.
2014-03-25 Jason Merrill <jason@redhat.com> 2014-03-25 Jason Merrill <jason@redhat.com>
......
...@@ -308,7 +308,7 @@ ...@@ -308,7 +308,7 @@
(lang_spec_driver): Use LIBSTDCXX_STATIC when not (lang_spec_driver): Use LIBSTDCXX_STATIC when not
shared_libgcc. shared_libgcc.
2008-11-05 Fabien Chene <fabien.chene@gmail.com> 2008-11-05 Fabien Chêne <fabien@gcc.gnu.org>
PR c++/32519 PR c++/32519
* cp-tree.h: Fix DECL_NONSTATIC_MEMBER_P to handle member template * cp-tree.h: Fix DECL_NONSTATIC_MEMBER_P to handle member template
......
...@@ -3127,13 +3127,13 @@ ...@@ -3127,13 +3127,13 @@
* typeck.c (cp_build_modify_expr): Complain about assignment to * typeck.c (cp_build_modify_expr): Complain about assignment to
array from init list. array from init list.
2010-05-10 Fabien Chêne <fabien.chene@gmail.com> 2010-05-10 Fabien Chêne <fabien@gcc.gnu.org>
PR c++/43719 PR c++/43719
* decl.c (check_initializer): strip array type before checking for * decl.c (check_initializer): Strip array type before checking for
uninitialized const or ref members. uninitialized const or ref members.
2010-05-07 Fabien Chêne <fabien.chene@gmail.com> 2010-05-07 Fabien Chêne <fabien@gcc.gnu.org>
PR c++/43951 PR c++/43951
* init.c (diagnose_uninitialized_cst_or_ref_member_1): Returns the * init.c (diagnose_uninitialized_cst_or_ref_member_1): Returns the
...@@ -3260,10 +3260,10 @@ ...@@ -3260,10 +3260,10 @@
(convert_arguments): Use warn_args_num to print the diagnostic (convert_arguments): Use warn_args_num to print the diagnostic
messages. messages.
2010-04-29 Fabien Chêne <fabien.chene@gmail.com> 2010-04-29 Fabien Chêne <fabien@gcc.gnu.org>
PR c++/43890 PR c++/43890
* init.c (diagnose_uninitialized_cst_or_ref_member): check for * init.c (diagnose_uninitialized_cst_or_ref_member): Check for
user-provided constructor while recursing. user-provided constructor while recursing.
2010-04-28 Manuel López-Ibáñez <manu@gcc.gnu.org> 2010-04-28 Manuel López-Ibáñez <manu@gcc.gnu.org>
...@@ -3277,10 +3277,10 @@ ...@@ -3277,10 +3277,10 @@
* init.c (perform_member_init): Check CLASS_TYPE_P. * init.c (perform_member_init): Check CLASS_TYPE_P.
2010-04-27 Fabien Chêne <fabien.chene@gmail.com> 2010-04-27 Fabien Chêne <fabien@gcc.gnu.org>
PR c++/29043 PR c++/29043
* init.c (perform_member_init): check for uninitialized const or * init.c (perform_member_init): Check for uninitialized const or
reference members, including array types. reference members, including array types.
2010-04-24 Jason Merrill <jason@redhat.com> 2010-04-24 Jason Merrill <jason@redhat.com>
...@@ -3331,7 +3331,7 @@ ...@@ -3331,7 +3331,7 @@
convert_like_real. convert_like_real.
* cp-tree.h: Adjust. * cp-tree.h: Adjust.
2010-04-27 Fabien Chêne <fabien.chene@gmail.com> 2010-04-27 Fabien Chêne <fabien@gcc.gnu.org>
Jason Merrill <jason@redhat.com> Jason Merrill <jason@redhat.com>
PR c++/42844 PR c++/42844
...@@ -3403,7 +3403,7 @@ ...@@ -3403,7 +3403,7 @@
* call.c (type_decays_to): Call cv_unqualified for non-class type. * call.c (type_decays_to): Call cv_unqualified for non-class type.
2010-04-12 Fabien Chene <fabien.chene@gmail.com> 2010-04-12 Fabien Chêne <fabien@gcc.gnu.org>>
PR c++/25811 PR c++/25811
* cp-tree.h (diagnose_uninitialized_cst_or_ref_member): Declare. * cp-tree.h (diagnose_uninitialized_cst_or_ref_member): Declare.
......
...@@ -3511,7 +3511,7 @@ ...@@ -3511,7 +3511,7 @@
2011-05-07 Fabien Chêne <fabien@gcc.gnu.org> 2011-05-07 Fabien Chêne <fabien@gcc.gnu.org>
PR c++/48859 PR c++/48859
* init.c (diagnose_uninitialized_cst_or_ref_member_1): stop the * init.c (diagnose_uninitialized_cst_or_ref_member_1): Stop the
recursion if there is user defined constructor. recursion if there is user defined constructor.
2011-05-09 Jason Merrill <jason@redhat.com> 2011-05-09 Jason Merrill <jason@redhat.com>
......
...@@ -2716,7 +2716,7 @@ ...@@ -2716,7 +2716,7 @@
2012-02-16 Fabien Chêne <fabien@gcc.gnu.org> 2012-02-16 Fabien Chêne <fabien@gcc.gnu.org>
PR c++/52126 PR c++/52126
* decl.c (xref_basetypes): call dependent_scope_p instead of * decl.c (xref_basetypes): Call dependent_scope_p instead of
dependent_type_p. dependent_type_p.
2012-02-16 Jason Merrill <jason@redhat.com> 2012-02-16 Jason Merrill <jason@redhat.com>
......
...@@ -694,11 +694,14 @@ perform_member_init (tree member, tree init) ...@@ -694,11 +694,14 @@ perform_member_init (tree member, tree init)
if (CP_TYPE_CONST_P (type) if (CP_TYPE_CONST_P (type)
&& init == NULL_TREE && init == NULL_TREE
&& default_init_uninitialized_part (type)) && default_init_uninitialized_part (type))
{
/* TYPE_NEEDS_CONSTRUCTING can be set just because we have a /* TYPE_NEEDS_CONSTRUCTING can be set just because we have a
vtable; still give this diagnostic. */ vtable; still give this diagnostic. */
permerror (DECL_SOURCE_LOCATION (current_function_decl), if (permerror (DECL_SOURCE_LOCATION (current_function_decl),
"uninitialized member %qD with %<const%> type %qT", "uninitialized const member in %q#T", type))
member, type); inform (DECL_SOURCE_LOCATION (member),
"%q#D should be initialized", member );
}
finish_expr_stmt (build_aggr_init (decl, init, flags, finish_expr_stmt (build_aggr_init (decl, init, flags,
tf_warning_or_error)); tf_warning_or_error));
} }
...@@ -710,13 +713,19 @@ perform_member_init (tree member, tree init) ...@@ -710,13 +713,19 @@ perform_member_init (tree member, tree init)
tree core_type; tree core_type;
/* member traversal: note it leaves init NULL */ /* member traversal: note it leaves init NULL */
if (TREE_CODE (type) == REFERENCE_TYPE) if (TREE_CODE (type) == REFERENCE_TYPE)
permerror (DECL_SOURCE_LOCATION (current_function_decl), {
"uninitialized reference member %qD", if (permerror (DECL_SOURCE_LOCATION (current_function_decl),
member); "uninitialized reference member in %q#T", type))
inform (DECL_SOURCE_LOCATION (member),
"%q#D should be initialized", member);
}
else if (CP_TYPE_CONST_P (type)) else if (CP_TYPE_CONST_P (type))
permerror (DECL_SOURCE_LOCATION (current_function_decl), {
"uninitialized member %qD with %<const%> type %qT", if (permerror (DECL_SOURCE_LOCATION (current_function_decl),
member, type); "uninitialized const member in %q#T", type))
inform (DECL_SOURCE_LOCATION (member),
"%q#D should be initialized", member );
}
core_type = strip_array_types (type); core_type = strip_array_types (type);
......
2014-04-01 Fabien Chêne <fabien@gcc.gnu.org>
* g++.dg/init/ctor4.C: Adjust.
* g++.dg/init/ctor4-1.C: New.
* g++.dg/cpp0x/defaulted2.C: Adjust.
2014-04-01 Richard Henderson <rth@redhat.com> 2014-04-01 Richard Henderson <rth@redhat.com>
PR target/60704 PR target/60704
......
...@@ -1814,7 +1814,7 @@ ...@@ -1814,7 +1814,7 @@
* gcc.dg/Warray-bounds-5.c: New test. * gcc.dg/Warray-bounds-5.c: New test.
* gcc.dg/Warray-bounds-6.c: New test. * gcc.dg/Warray-bounds-6.c: New test.
2008-11-05 Fabien Chene <fabien.chene@gmail.com> 2008-11-05 Fabien Chene <fabien@gcc.gnu.org>
PR c++/32519 PR c++/32519
* g++.dg/template/pr32519.C: New test. * g++.dg/template/pr32519.C: New test.
......
...@@ -11264,7 +11264,7 @@ ...@@ -11264,7 +11264,7 @@
* g++.dg/cpp0x/initlist26.C: Adjust. * g++.dg/cpp0x/initlist26.C: Adjust.
* g++.dg/cpp0x/initlist28.C: Adjust. * g++.dg/cpp0x/initlist28.C: Adjust.
2010-05-10 Fabien Chêne <fabien.chene@gmail.com> 2010-05-10 Fabien Chêne <fabien@gcc.gnu.org>
PR c++/43719 PR c++/43719
* g++.dg/init/pr43719.C: New. * g++.dg/init/pr43719.C: New.
...@@ -11389,7 +11389,7 @@ ...@@ -11389,7 +11389,7 @@
* gnat.dg/sizetype3.ad[sb]: New test. * gnat.dg/sizetype3.ad[sb]: New test.
* gnat.dg/sizetype3_pkg.ads: New helper. * gnat.dg/sizetype3_pkg.ads: New helper.
2010-05-07 Fabien Chêne <fabien.chene@gmail.com> 2010-05-07 Fabien Chêne <fabien@gcc.gnu.org>
PR c++/43951 PR c++/43951
* g++.dg/init/new29.C: New. * g++.dg/init/new29.C: New.
...@@ -11738,12 +11738,6 @@ ...@@ -11738,12 +11738,6 @@
* gcc.dg/tree-ssa/builtin-free.c: New testcase. * gcc.dg/tree-ssa/builtin-free.c: New testcase.
2010-04-29 Fabien Chêne <fabien.chene@gmail.com>
PR c++/43890
* init.c (diagnose_uninitialized_cst_or_ref_member): check for
user-provided constructor while recursing.
2010-04-29 Janus Weil <janus@gcc.gnu.org> 2010-04-29 Janus Weil <janus@gcc.gnu.org>
PR fortran/42274 PR fortran/42274
...@@ -11866,7 +11860,7 @@ ...@@ -11866,7 +11860,7 @@
* g++.dg/template/pr23510.C: Update. * g++.dg/template/pr23510.C: Update.
* lib/prune.exp: Filter out 'recursively instantiated'. * lib/prune.exp: Filter out 'recursively instantiated'.
2010-04-27 Fabien Chêne <fabien.chene@gmail.com> 2010-04-27 Fabien Chêne <fabien@gcc.gnu.org>
PR c++/29043 PR c++/29043
* g++.dg/init/pr29043.C: New. * g++.dg/init/pr29043.C: New.
...@@ -11898,7 +11892,7 @@ ...@@ -11898,7 +11892,7 @@
* g++.dg/template/sfinae17.C: New. * g++.dg/template/sfinae17.C: New.
* g++.dg/template/sfinae18.C: New. * g++.dg/template/sfinae18.C: New.
2010-04-27 Fabien Chêne <fabien.chene@gmail.com> 2010-04-27 Fabien Chêne <fabien@gcc.gnu.org>
* g++.dg/init/pr42844.C: New. * g++.dg/init/pr42844.C: New.
* g++.dg/cpp0x/pr42844-2.C: New. * g++.dg/cpp0x/pr42844-2.C: New.
...@@ -12500,7 +12494,7 @@ ...@@ -12500,7 +12494,7 @@
* g++.dg/cpp0x/lambda/lambda-conv4.C: New. * g++.dg/cpp0x/lambda/lambda-conv4.C: New.
* g++.dg/cpp0x/lambda/lambda-deduce2.C: New. * g++.dg/cpp0x/lambda/lambda-deduce2.C: New.
2010-04-12 Fabien Chene <fabien.chene@gmail.com> 2010-04-12 Fabien Chene <fabien@gcc.gnu.org>
PR c++/25811 PR c++/25811
* g++.dg/init/pr25811.C: New test. * g++.dg/init/pr25811.C: New test.
......
...@@ -35,7 +35,7 @@ struct D: public C ...@@ -35,7 +35,7 @@ struct D: public C
struct E struct E
{ {
const B b; const B b; // { dg-message "should be initialized" }
E() { } // { dg-error "uninitialized" } E() { } // { dg-error "uninitialized" }
}; };
......
// { dg-do compile }
class foo {
public:
foo();
};
class bar: public foo { // { dg-error "uninitialized" }
// { dg-message "implicitly deleted" "" { target c++11 } 8 }
private:
int const a; // { dg-message "should be initialized" }
};
foo::foo() {
}
int main(int argc, char **argv)
{
bar x; // { dg-error "deleted" "" { target c++11 } }
// { dg-message "synthesized" "" { target { ! c++11 } } 19 }
}
...@@ -6,9 +6,10 @@ public: ...@@ -6,9 +6,10 @@ public:
foo(); foo();
}; };
class bar: public foo { // { dg-error "reference|bar::bar" } class bar: public foo { // { dg-error "uninitialized" }
// { dg-message "implicitly deleted" "" { target c++11 } 9 }
private: private:
int &a; int &a; // { dg-message "should be initialized" }
}; };
foo::foo() { foo::foo() {
...@@ -16,5 +17,6 @@ foo::foo() { ...@@ -16,5 +17,6 @@ foo::foo() {
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
bar x; // { dg-message "synthesized|deleted" } bar x; // { dg-error "deleted" "" { target c++11 } }
// { dg-message "synthesized" "" { target { ! c++11 } } 20 }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment