From 1b27500048b97fbdf53c5407e2dbc8f91c439481 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Thu, 29 Aug 2013 11:20:16 +0000 Subject: [PATCH] re PR middle-end/57287 (Bogus uninitialized warning with abnormal control flow) 2013-08-29 Richard Biener PR middle-end/57287 * tree-ssa-copy.c (may_propagate_copy): Allow propagating of default defs that appear in abnormal PHI nodes. * gcc.dg/pr57287-2.c: New testcase. From-SVN: r202069 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr57287-2.c | 35 ++++++++++++++++++++++++++++++++ gcc/tree-ssa-copy.c | 8 +++++++- 4 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/pr57287-2.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2444b92cda7..ad77502e277 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2013-08-29 Richard Biener + + PR middle-end/57287 + * tree-ssa-copy.c (may_propagate_copy): Allow propagating + of default defs that appear in abnormal PHI nodes. + 2013-08-29 Richard Biener PR tree-optimization/57685 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9b9ff4240ca..d95d535a92c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-08-29 Richard Biener + + PR middle-end/57287 + * gcc.dg/pr57287-2.c: New testcase. + 2013-08-29 Richard Biener PR tree-optimization/57685 diff --git a/gcc/testsuite/gcc.dg/pr57287-2.c b/gcc/testsuite/gcc.dg/pr57287-2.c new file mode 100644 index 00000000000..5422e148cbe --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr57287-2.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wall" } */ + +#include + +struct node +{ + struct node *next; + char *name; +} *list; + +struct node *list; +struct node *head (void); + +sigjmp_buf *bar (void); + +int baz (void) +{ + struct node *n; + int varseen = 0; + + list = head (); + for (n = list; n; n = n->next) + { + if (!varseen) + varseen = 1; + + sigjmp_buf *buf = bar (); /* { dg-bogus "may be used uninitialized" "" } */ + __sigsetjmp (*buf, 1); + } + + if (!varseen) + return 0; + return 1; +} diff --git a/gcc/tree-ssa-copy.c b/gcc/tree-ssa-copy.c index 75ab54aeda6..9bc455c61a7 100644 --- a/gcc/tree-ssa-copy.c +++ b/gcc/tree-ssa-copy.c @@ -60,7 +60,13 @@ may_propagate_copy (tree dest, tree orig) /* If ORIG flows in from an abnormal edge, it cannot be propagated. */ if (TREE_CODE (orig) == SSA_NAME - && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (orig)) + && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (orig) + /* If it is the default definition and an automatic variable then + we can though and it is important that we do to avoid + uninitialized regular copies. */ + && !(SSA_NAME_IS_DEFAULT_DEF (orig) + && (SSA_NAME_VAR (orig) == NULL_TREE + || TREE_CODE (SSA_NAME_VAR (orig)) == VAR_DECL))) return false; /* If DEST is an SSA_NAME that flows from an abnormal edge, then it -- 2.30.2