From 42694189bdade115459859e898e0b78d1cdb033c Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 27 Jul 2010 11:43:59 +0200 Subject: [PATCH] re PR tree-optimization/45083 (strange warning text from gcc) PR tree-optimization/45083 * tree-inline.c (add_local_variables): Also remap DECL_DEBUG_EXPR. * gcc.dg/pr45083.c: New test. From-SVN: r162559 --- gcc/ChangeLog | 5 +++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr45083.c | 25 +++++++++++++++++++++++++ gcc/tree-inline.c | 19 ++++++++++++++++++- 4 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/pr45083.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6983da721b4..f9a1b2f53f3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2010-07-27 Jakub Jelinek + + PR tree-optimization/45083 + * tree-inline.c (add_local_variables): Also remap DECL_DEBUG_EXPR. + 2010-07-27 Bernd Schmidt * postreload.c (reload_combine_recognize_const_pattern): Move test diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9ce38788dd2..93bfc706069 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-07-27 Jakub Jelinek + + PR tree-optimization/45083 + * gcc.dg/pr45083.c: New test. + 2010-07-26 Tobias Burnus PR fortran/40873 diff --git a/gcc/testsuite/gcc.dg/pr45083.c b/gcc/testsuite/gcc.dg/pr45083.c new file mode 100644 index 00000000000..c9a4dbfe191 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr45083.c @@ -0,0 +1,25 @@ +/* PR tree-optimization/45083 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized" } */ + +struct S { char *a; unsigned b; unsigned c; }; +extern int foo (const char *); +extern void bar (int, int); + +static void +baz (void) +{ + struct S cs[1]; /* { dg-message "was declared here" } */ + switch (cs->b) /* { dg-warning "cs\[^\n\r\]*\\.b\[^\n\r\]*is used uninitialized" } */ + { + case 101: + if (foo (cs->a)) /* { dg-warning "cs\[^\n\r\]*\\.a\[^\n\r\]*may be used uninitialized" } */ + bar (cs->c, cs->b); /* { dg-warning "cs\[^\n\r\]*\\.c\[^\n\r\]*may be used uninitialized" } */ + } +} + +void +test (void) +{ + baz (); +} diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index dc09c29b6ea..81d6cfb4c50 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -3687,7 +3687,24 @@ add_local_variables (struct function *callee, struct function *caller, add_local_decl (caller, var); } else if (!can_be_nonlocal (var, id)) - add_local_decl (caller, remap_decl (var, id)); + { + tree new_var = remap_decl (var, id); + + /* Remap debug-expressions. */ + if (TREE_CODE (new_var) == VAR_DECL + && DECL_DEBUG_EXPR_IS_FROM (new_var) + && new_var != var) + { + tree tem = DECL_DEBUG_EXPR (var); + bool old_regimplify = id->regimplify; + id->remapping_type_depth++; + walk_tree (&tem, copy_tree_body_r, id, NULL); + id->remapping_type_depth--; + id->regimplify = old_regimplify; + SET_DECL_DEBUG_EXPR (new_var, tem); + } + add_local_decl (caller, new_var); + } } /* Fetch callee declaration from the call graph edge going from NODE and