From 15f4769a12dd1640fcf6608c34eea46d8da86fbb Mon Sep 17 00:00:00 2001 From: Marek Polacek Date: Mon, 8 Apr 2019 19:31:00 +0000 Subject: [PATCH] typeck2.c (digest_init_r): Don't condition the object slicing warning on flag_checking. * typeck2.c (digest_init_r): Don't condition the object slicing warning on flag_checking. From-SVN: r270215 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/typeck2.c | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 74e2b7d95c6..9df42489a4e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2019-04-08 Marek Polacek + + * typeck2.c (digest_init_r): Don't condition the object slicing warning + on flag_checking. + 2019-04-08 Paolo Carlini PR c++/89914 diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index fa98b1cb8b5..55b84f043f4 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -1200,8 +1200,7 @@ digest_init_r (tree type, tree init, int nested, int flags, /* "If T is a class type and the initializer list has a single element of type cv U, where U is T or a class derived from T, the object is initialized from that element." */ - if (flag_checking - && cxx_dialect >= cxx11 + if (cxx_dialect >= cxx11 && BRACE_ENCLOSED_INITIALIZER_P (stripped_init) && CONSTRUCTOR_NELTS (stripped_init) == 1 && ((CLASS_TYPE_P (type) && !CLASSTYPE_NON_AGGREGATE (type)) @@ -1228,7 +1227,7 @@ digest_init_r (tree type, tree init, int nested, int flags, "results in object slicing", TREE_TYPE (field))) inform (loc, "remove %<{ }%> around initializer"); } - else + else if (flag_checking) /* We should have fixed this in reshape_init. */ gcc_unreachable (); } -- 2.30.2