mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-26 07:50:27 +08:00
re PR c++/34772 (self-initialisation does not silence uninitialised warnings (-Winit-self ignored))
PR c++/34772 * decl.c (initialize_local_var): Use DECL_INITIAL for simple initialization. From-SVN: r173582
This commit is contained in:
parent
b5da71d416
commit
03808d178a
@ -1,3 +1,9 @@
|
||||
2011-05-09 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/34772
|
||||
* decl.c (initialize_local_var): Use DECL_INITIAL for simple
|
||||
initialization.
|
||||
|
||||
2011-05-08 Ville Voutilainen <ville.voutilainen@gmail.com>
|
||||
|
||||
Implement final/override for member functions.
|
||||
|
@ -5689,21 +5689,32 @@ initialize_local_var (tree decl, tree init)
|
||||
/* Perform the initialization. */
|
||||
if (init)
|
||||
{
|
||||
int saved_stmts_are_full_exprs_p;
|
||||
if (TREE_CODE (init) == INIT_EXPR
|
||||
&& !TREE_SIDE_EFFECTS (TREE_OPERAND (init, 1)))
|
||||
{
|
||||
/* Stick simple initializers in DECL_INITIAL so that
|
||||
-Wno-init-self works (c++/34772). */
|
||||
gcc_assert (TREE_OPERAND (init, 0) == decl);
|
||||
DECL_INITIAL (decl) = TREE_OPERAND (init, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
int saved_stmts_are_full_exprs_p;
|
||||
|
||||
/* If we're only initializing a single object, guard the destructors
|
||||
of any temporaries used in its initializer with its destructor.
|
||||
This isn't right for arrays because each element initialization is
|
||||
a full-expression. */
|
||||
if (cleanup && TREE_CODE (type) != ARRAY_TYPE)
|
||||
wrap_temporary_cleanups (init, cleanup);
|
||||
/* If we're only initializing a single object, guard the
|
||||
destructors of any temporaries used in its initializer with
|
||||
its destructor. This isn't right for arrays because each
|
||||
element initialization is a full-expression. */
|
||||
if (cleanup && TREE_CODE (type) != ARRAY_TYPE)
|
||||
wrap_temporary_cleanups (init, cleanup);
|
||||
|
||||
gcc_assert (building_stmt_tree ());
|
||||
saved_stmts_are_full_exprs_p = stmts_are_full_exprs_p ();
|
||||
current_stmt_tree ()->stmts_are_full_exprs_p = 1;
|
||||
finish_expr_stmt (init);
|
||||
current_stmt_tree ()->stmts_are_full_exprs_p =
|
||||
saved_stmts_are_full_exprs_p;
|
||||
gcc_assert (building_stmt_tree ());
|
||||
saved_stmts_are_full_exprs_p = stmts_are_full_exprs_p ();
|
||||
current_stmt_tree ()->stmts_are_full_exprs_p = 1;
|
||||
finish_expr_stmt (init);
|
||||
current_stmt_tree ()->stmts_are_full_exprs_p =
|
||||
saved_stmts_are_full_exprs_p;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set this to 0 so we can tell whether an aggregate which was
|
||||
|
@ -1,3 +1,14 @@
|
||||
2011-05-09 Jason Merrill <jason@redhat.com>
|
||||
|
||||
* gcc.dg/gcc.dg/uninit-D.c: Move to c-c++-common.
|
||||
* gcc.dg/gcc.dg/uninit-D-O0.c: Move to c-c++-common.
|
||||
* gcc.dg/gcc.dg/uninit-E.c: Move to c-c++-common.
|
||||
* gcc.dg/gcc.dg/uninit-E-O0.c: Move to c-c++-common.
|
||||
* gcc.dg/gcc.dg/uninit-F.c: Move to c-c++-common.
|
||||
* gcc.dg/gcc.dg/uninit-F-O0.c: Move to c-c++-common.
|
||||
* gcc.dg/gcc.dg/uninit-G.c: Move to c-c++-common.
|
||||
* gcc.dg/gcc.dg/uninit-G-O0.c: Move to c-c++-common.
|
||||
|
||||
2011-05-08 Ville Voutilainen <ville.voutilainen@gmail.com>
|
||||
|
||||
* g++.dg/inherit/virtual9.C: New.
|
||||
|
Loading…
x
Reference in New Issue
Block a user