diff options
author | Richard Guenther <rguenther@suse.de> | 2008-01-29 15:47:19 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2008-01-29 15:47:19 +0000 |
commit | 4f5c64b8ace84098b6222b495294765fb3fc38c2 (patch) | |
tree | 7b6cda1d150280c50f4c6d2bbb388db41dc4fa4d /gcc/tree-inline.c | |
parent | 7b3e2d465d6f267d34a18b46c1ab6650c67785d9 (diff) | |
download | gcc-4f5c64b8ace84098b6222b495294765fb3fc38c2.zip gcc-4f5c64b8ace84098b6222b495294765fb3fc38c2.tar.gz gcc-4f5c64b8ace84098b6222b495294765fb3fc38c2.tar.bz2 |
re PR tree-optimization/35006 (Segfault in remove_unused_locals with nested functions)
2008-01-29 Richard Guenther <rguenther@suse.de>
PR middle-end/35006
* tree-inline.h (struct copy_body_data): Add remapping_type_depth
field.
* tree-inline.c (remap_type): Increment remapping_type_depth
around remapping types.
(copy_body_r): Only add referenced variables if they are referenced
from code, not types.
* gcc.c-torture/compile/pr35006.c: New testcase.
From-SVN: r131939
Diffstat (limited to 'gcc/tree-inline.c')
-rw-r--r-- | gcc/tree-inline.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index 636e37d..d2ef961 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -409,6 +409,7 @@ tree remap_type (tree type, copy_body_data *id) { tree *node; + tree tmp; if (type == NULL) return type; @@ -425,7 +426,11 @@ remap_type (tree type, copy_body_data *id) return type; } - return remap_type_1 (type, id); + id->remapping_type_depth++; + tmp = remap_type_1 (type, id); + id->remapping_type_depth--; + + return tmp; } static tree @@ -723,9 +728,10 @@ copy_body_r (tree *tp, int *walk_subtrees, void *data) tweak some special cases. */ copy_tree_r (tp, walk_subtrees, NULL); - /* Global variables we didn't seen yet needs to go into referenced - vars. */ - if (gimple_in_ssa_p (cfun) && TREE_CODE (*tp) == VAR_DECL) + /* Global variables we haven't seen yet needs to go into referenced + vars. If not referenced from types only. */ + if (gimple_in_ssa_p (cfun) && TREE_CODE (*tp) == VAR_DECL + && id->remapping_type_depth == 0) add_referenced_var (*tp); /* If EXPR has block defined, map it to newly constructed block. |