From 759830388df007ca021ed004e927a2433852071a Mon Sep 17 00:00:00 2001 From: Diego Novillo Date: Fri, 17 Dec 2004 22:20:33 +0000 Subject: [PATCH] tree-optimize.c (init_tree_optimization_passes): Run pass_late_warn_uninitialized before the last DCE run. tree-optimization/18501 * tree-optimize.c (init_tree_optimization_passes): Run pass_late_warn_uninitialized before the last DCE run. testsuite/ChangeLog: * gcc.dg/pr18501.c: New test. * gcc.dg/uninit-5.c: XFAIL. * gcc.dg/uninit-9.c: XFAIL. From-SVN: r92337 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gcc.dg/pr18501.c | 20 ++++++++++++++++++++ gcc/testsuite/gcc.dg/uninit-5.c | 4 ++-- gcc/testsuite/gcc.dg/uninit-9.c | 2 +- gcc/tree-optimize.c | 11 ++++++++++- 6 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr18501.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4e51583d5db..c08d172211a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2004-12-17 Diego Novillo + + tree-optimization/18501 + * tree-optimize.c (init_tree_optimization_passes): Run + pass_late_warn_uninitialized before the last DCE run. + 2004-12-17 Richard Henderson * config/i386/i386.c (x86_64_reg_class_name): Re-indent. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6dbca4ac5d6..a2e5f6f1a71 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2004-12-17 Diego Novillo + + * gcc.dg/pr18501.c: New test. + * gcc.dg/uninit-5.c: XFAIL. + * gcc.dg/uninit-9.c: XFAIL. + 2004-12-17 Dale Johannesen * gcc.dg/20041213-1.c: New. diff --git a/gcc/testsuite/gcc.dg/pr18501.c b/gcc/testsuite/gcc.dg/pr18501.c new file mode 100644 index 00000000000..bcd20717f9e --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr18501.c @@ -0,0 +1,20 @@ +/* Expected uninitialized variable warning. */ + +/* { dg-do compile } */ +/* { dg-options "-O -Wuninitialized" } */ + +unsigned bmp_iter_set (); +int something (void); + +void +bitmap_print_value_set (void) +{ + unsigned first; /* { dg-warning "may be used" "conditional in loop" } */ + + for (; bmp_iter_set (); ) + { + if (!first) + something (); + first = 0; + } +} diff --git a/gcc/testsuite/gcc.dg/uninit-5.c b/gcc/testsuite/gcc.dg/uninit-5.c index ae7a8de7646..21ac9eec6f8 100644 --- a/gcc/testsuite/gcc.dg/uninit-5.c +++ b/gcc/testsuite/gcc.dg/uninit-5.c @@ -9,7 +9,7 @@ extern void foo(void); void func1(int cond) { - int x; /* { dg-bogus "x" "uninitialized variable warning" } */ + int x; /* { dg-bogus "x" "uninitialized variable warning" { xfail *-*-* } } */ if(cond) x = 1; @@ -23,7 +23,7 @@ func1(int cond) void func2 (int cond) { - int x; /* { dg-bogus "x" "uninitialized variable warning" } */ + int x; /* { dg-bogus "x" "uninitialized variable warning" { xfail *-*-* } } */ int flag = 0; if(cond) diff --git a/gcc/testsuite/gcc.dg/uninit-9.c b/gcc/testsuite/gcc.dg/uninit-9.c index 2a8ccb69f32..62681f9e0fd 100644 --- a/gcc/testsuite/gcc.dg/uninit-9.c +++ b/gcc/testsuite/gcc.dg/uninit-9.c @@ -23,7 +23,7 @@ func(struct foo *list, int count) { int n_clobbers = 0; int i; - struct foo **clob_list; /* { dg-bogus "clob_list" "uninitialized variable warning" } */ + struct foo **clob_list; /* { dg-bogus "clob_list" "uninitialized variable warning" { xfail *-*-* } } */ if(list[0].type == PARALLEL) { diff --git a/gcc/tree-optimize.c b/gcc/tree-optimize.c index 9f58f533731..eae39df90aa 100644 --- a/gcc/tree-optimize.c +++ b/gcc/tree-optimize.c @@ -381,12 +381,21 @@ init_tree_optimization_passes (void) NEXT_PASS (pass_loop); NEXT_PASS (pass_dominator); NEXT_PASS (pass_redundant_phi); + /* FIXME: If DCE is not run before checking for uninitialized uses, + we may get false warnings (e.g., testsuite/gcc.dg/uninit-5.c). + However, this also causes us to misdiagnose cases that should be + real warnings (e.g., testsuite/gcc.dg/pr18501.c). + + To fix the false positives in uninit-5.c, we would have to + account for the predicates protecting the set and the use of each + variable. Using a representation like Gated Single Assignment + may help. */ + NEXT_PASS (pass_late_warn_uninitialized); NEXT_PASS (pass_cd_dce); NEXT_PASS (pass_dse); NEXT_PASS (pass_forwprop); NEXT_PASS (pass_phiopt); NEXT_PASS (pass_tail_calls); - NEXT_PASS (pass_late_warn_uninitialized); NEXT_PASS (pass_del_ssa); NEXT_PASS (pass_nrv); NEXT_PASS (pass_remove_useless_vars);