From 5c2961cf38a69f2579718f369753c7939a7e5ad1 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Wed, 11 Sep 2013 12:20:07 +0000 Subject: [PATCH] re PR c++/58377 (spurious "may be used uninitialized" warning with -Og) 2013-09-11 Richard Biener PR middle-end/58377 * passes.def: Split critical edges before late uninit warning passes. * tree-cfg.c (pass_split_crit_edges): Implement clone method. * g++.dg/uninit-pred-4.C: New testcase. From-SVN: r202496 --- gcc/ChangeLog | 6 ++++++ gcc/passes.def | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/uninit-pred-4.C | 16 ++++++++++++++++ gcc/tree-cfg.c | 1 + 5 files changed, 34 insertions(+) create mode 100644 gcc/testsuite/g++.dg/uninit-pred-4.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e5e1702e954f..5e9b2079e375 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2013-09-11 Richard Biener + + PR middle-end/58377 + * passes.def: Split critical edges before late uninit warning passes. + * tree-cfg.c (pass_split_crit_edges): Implement clone method. + 2013-09-11 Jakub Jelinek PR tree-optimization/58385 diff --git a/gcc/passes.def b/gcc/passes.def index 736a28b64dc9..635b4c464e8d 100644 --- a/gcc/passes.def +++ b/gcc/passes.def @@ -249,6 +249,9 @@ along with GCC; see the file COPYING3. If not see account for the predicates protecting the set and the use of each variable. Using a representation like Gated Single Assignment may help. */ + /* Split critical edges before late uninit warning to reduce the + number of false positives from it. */ + NEXT_PASS (pass_split_crit_edges); NEXT_PASS (pass_late_warn_uninitialized); NEXT_PASS (pass_dse); NEXT_PASS (pass_forwprop); @@ -282,6 +285,9 @@ along with GCC; see the file COPYING3. If not see /* ??? We do want some kind of loop invariant motion, but we possibly need to adjust LIM to be more friendly towards preserving accurate debug information here. */ + /* Split critical edges before late uninit warning to reduce the + number of false positives from it. */ + NEXT_PASS (pass_split_crit_edges); NEXT_PASS (pass_late_warn_uninitialized); NEXT_PASS (pass_uncprop); NEXT_PASS (pass_local_pure_const); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c924967ed3be..49e28adb46bc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-09-11 Richard Biener + + PR middle-end/58377 + * g++.dg/uninit-pred-4.C: New testcase. + 2013-09-11 Jakub Jelinek PR tree-optimization/58385 diff --git a/gcc/testsuite/g++.dg/uninit-pred-4.C b/gcc/testsuite/g++.dg/uninit-pred-4.C new file mode 100644 index 000000000000..94ab13c50d6f --- /dev/null +++ b/gcc/testsuite/g++.dg/uninit-pred-4.C @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-Wuninitialized -Og" } */ + +int pop (); +int pop_first_bucket; + +int my_pop () +{ + int out; // { dg-bogus "uninitialized" "uninitialized variable warning" } + + while (pop_first_bucket) + if (pop_first_bucket && (out = pop())) + return out; + + return 0; +} diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index c74b98859336..dfe10016be54 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -7929,6 +7929,7 @@ public: /* opt_pass methods: */ unsigned int execute () { return split_critical_edges (); } + opt_pass * clone () { return new pass_split_crit_edges (ctxt_); } }; // class pass_split_crit_edges } // anon namespace -- 2.43.0