Commit dc874b53 by Richard Guenther Committed by Richard Biener

re PR middle-end/38851 (Compiler warns about uninitialized variable that is an…

re PR middle-end/38851 (Compiler warns about uninitialized variable that is an object with a constructor)

2009-01-26  Richard Guenther  <rguenther@suse.de>

	PR middle-end/38851
	* Makefile.in (tree-ssa-dse.o): Add langhooks.h.
	* tree-ssa-dse.c: Include langhooks.h
	(execute_simple_dse): Remove stores with zero size.

	* g++.dg/warn/Wuninitialized-1.C: New testcase.

From-SVN: r143672
parent 20d4bdcb
2009-01-26 Richard Guenther <rguenther@suse.de>
PR middle-end/38851
* Makefile.in (tree-ssa-dse.o): Add langhooks.h.
* tree-ssa-dse.c: Include langhooks.h
(execute_simple_dse): Remove stores with zero size.
2009-01-24 Jakub Jelinek <jakub@redhat.com> 2009-01-24 Jakub Jelinek <jakub@redhat.com>
PR c/38957 PR c/38957
......
...@@ -2110,7 +2110,7 @@ tree-outof-ssa.o : tree-outof-ssa.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \ ...@@ -2110,7 +2110,7 @@ tree-outof-ssa.o : tree-outof-ssa.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
tree-ssa-dse.o : tree-ssa-dse.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ tree-ssa-dse.o : tree-ssa-dse.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TM_H) $(GGC_H) $(TREE_H) $(RTL_H) $(TM_P_H) $(BASIC_BLOCK_H) \ $(TM_H) $(GGC_H) $(TREE_H) $(RTL_H) $(TM_P_H) $(BASIC_BLOCK_H) \
$(TREE_FLOW_H) tree-pass.h $(TREE_DUMP_H) domwalk.h $(FLAGS_H) \ $(TREE_FLOW_H) tree-pass.h $(TREE_DUMP_H) domwalk.h $(FLAGS_H) \
$(DIAGNOSTIC_H) $(TIMEVAR_H) $(DIAGNOSTIC_H) $(TIMEVAR_H) langhooks.h
tree-ssa-forwprop.o : tree-ssa-forwprop.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ tree-ssa-forwprop.o : tree-ssa-forwprop.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TM_H) $(GGC_H) $(TREE_H) $(RTL_H) $(TM_P_H) $(BASIC_BLOCK_H) \ $(TM_H) $(GGC_H) $(TREE_H) $(RTL_H) $(TM_P_H) $(BASIC_BLOCK_H) \
$(TREE_FLOW_H) tree-pass.h $(TREE_DUMP_H) $(DIAGNOSTIC_H) $(TIMEVAR_H) \ $(TREE_FLOW_H) tree-pass.h $(TREE_DUMP_H) $(DIAGNOSTIC_H) $(TIMEVAR_H) \
......
2009-01-26 Richard Guenther <rguenther@suse.de>
PR middle-end/38851
* g++.dg/warn/Wuninitialized-1.C: New testcase.
2009-01-25 Hans-Peter Nilsson <hp@axis.com> 2009-01-25 Hans-Peter Nilsson <hp@axis.com>
* gcc.dg/bitfld-15.c: Gate warning on target * gcc.dg/bitfld-15.c: Gate warning on target
......
/* { dg-options "-O2 -Wuninitialized" } */
struct Empty { Empty() {} }; /* { dg-bogus "uninitialized" } */
struct Other {
Other(const Empty& e_) : e(e_) {}
Empty e;
};
void bar(Other&);
void foo()
{
Empty e;
Other o(e);
bar(o);
}
...@@ -34,6 +34,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -34,6 +34,7 @@ along with GCC; see the file COPYING3. If not see
#include "tree-dump.h" #include "tree-dump.h"
#include "domwalk.h" #include "domwalk.h"
#include "flags.h" #include "flags.h"
#include "langhooks.h"
/* This file implements dead store elimination. /* This file implements dead store elimination.
...@@ -660,20 +661,35 @@ execute_simple_dse (void) ...@@ -660,20 +661,35 @@ execute_simple_dse (void)
tree op; tree op;
bool removed = false; bool removed = false;
ssa_op_iter iter; ssa_op_iter iter;
tree size;
if (gimple_stored_syms (stmt) if (is_gimple_assign (stmt)
&& !bitmap_empty_p (gimple_stored_syms (stmt)) && AGGREGATE_TYPE_P (TREE_TYPE (gimple_assign_lhs (stmt)))
&& (is_gimple_assign (stmt) && (size = lang_hooks.expr_size (gimple_assign_lhs (stmt)))
|| (is_gimple_call (stmt) && integer_zerop (size))
&& gimple_call_lhs (stmt))) {
&& !bitmap_intersect_p (gimple_stored_syms (stmt), variables_loaded)) if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, " Deleted zero-sized store '");
print_gimple_stmt (dump_file, stmt, 0, dump_flags);
fprintf (dump_file, "'\n");
}
removed = true;
gsi_remove (&gsi, true);
todo |= TODO_cleanup_cfg;
}
else if (gimple_stored_syms (stmt)
&& !bitmap_empty_p (gimple_stored_syms (stmt))
&& (is_gimple_assign (stmt)
|| (is_gimple_call (stmt)
&& gimple_call_lhs (stmt)))
&& !bitmap_intersect_p (gimple_stored_syms (stmt),
variables_loaded))
{ {
unsigned int i; unsigned int i;
bitmap_iterator bi; bitmap_iterator bi;
bool dead = true; bool dead = true;
/* See if STMT only stores to write-only variables and /* See if STMT only stores to write-only variables and
verify that there are no volatile operands. tree-ssa-operands verify that there are no volatile operands. tree-ssa-operands
sets has_volatile_ops flag for all statements involving sets has_volatile_ops flag for all statements involving
......
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