Commit 03808d17 by Jason Merrill Committed by Jason Merrill

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
parent b5da71d4
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> 2011-05-08 Ville Voutilainen <ville.voutilainen@gmail.com>
Implement final/override for member functions. Implement final/override for member functions.
......
...@@ -5689,21 +5689,32 @@ initialize_local_var (tree decl, tree init) ...@@ -5689,21 +5689,32 @@ initialize_local_var (tree decl, tree init)
/* Perform the initialization. */ /* Perform the initialization. */
if (init) 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 /* If we're only initializing a single object, guard the
of any temporaries used in its initializer with its destructor. destructors of any temporaries used in its initializer with
This isn't right for arrays because each element initialization is its destructor. This isn't right for arrays because each
a full-expression. */ element initialization is a full-expression. */
if (cleanup && TREE_CODE (type) != ARRAY_TYPE) if (cleanup && TREE_CODE (type) != ARRAY_TYPE)
wrap_temporary_cleanups (init, cleanup); wrap_temporary_cleanups (init, cleanup);
gcc_assert (building_stmt_tree ()); gcc_assert (building_stmt_tree ());
saved_stmts_are_full_exprs_p = stmts_are_full_exprs_p (); saved_stmts_are_full_exprs_p = stmts_are_full_exprs_p ();
current_stmt_tree ()->stmts_are_full_exprs_p = 1; current_stmt_tree ()->stmts_are_full_exprs_p = 1;
finish_expr_stmt (init); finish_expr_stmt (init);
current_stmt_tree ()->stmts_are_full_exprs_p = current_stmt_tree ()->stmts_are_full_exprs_p =
saved_stmts_are_full_exprs_p; saved_stmts_are_full_exprs_p;
}
} }
/* Set this to 0 so we can tell whether an aggregate which was /* Set this to 0 so we can tell whether an aggregate which was
......
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> 2011-05-08 Ville Voutilainen <ville.voutilainen@gmail.com>
* g++.dg/inherit/virtual9.C: New. * g++.dg/inherit/virtual9.C: New.
......
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