diff options
author | Meador Inge <meadori@codesourcery.com> | 2012-06-21 20:20:30 +0000 |
---|---|---|
committer | Meador Inge <meadori@gcc.gnu.org> | 2012-06-21 20:20:30 +0000 |
commit | b6fbbea3ca4892390b643d3c2c1bf44a1a428c88 (patch) | |
tree | 0c88a3c22f7f5ed4598f0e757beea52db59e9943 /gcc/c-decl.c | |
parent | 0619103bb2ec9b0c23df7b8d9aab613459090b16 (diff) | |
download | gcc-b6fbbea3ca4892390b643d3c2c1bf44a1a428c88.zip gcc-b6fbbea3ca4892390b643d3c2c1bf44a1a428c88.tar.gz gcc-b6fbbea3ca4892390b643d3c2c1bf44a1a428c88.tar.bz2 |
re PR c/53702 (ICE with -Wall and nested functions and unused typedef)
PR c/53702
* c-decl.c (c_push_function_context): Restore the behavior to reuse
the language function allocated for -Wunused-local-typedefs.
(c_pop_function_context): If necessary, clear the language function
created in c_push_function_context. Always clear out the
x_cur_stmt_list field of the restored language function.
testsuite/
* gcc.dg/Wunused-local-typedefs.c: New testcase.
From-SVN: r188860
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r-- | gcc/c-decl.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 9622b12..bbb437d 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -8579,9 +8579,11 @@ check_for_loop_decls (location_t loc, bool turn_off_iso_c99_error) void c_push_function_context (void) { - struct language_function *p; - p = ggc_alloc_language_function (); - cfun->language = p; + struct language_function *p = cfun->language; + /* cfun->language might have been already allocated by the use of + -Wunused-local-typedefs. In that case, just re-use it. */ + if (p == NULL) + cfun->language = p = ggc_alloc_cleared_language_function (); p->base.x_stmt_tree = c_stmt_tree; c_stmt_tree.x_cur_stmt_list @@ -8607,7 +8609,12 @@ c_pop_function_context (void) pop_function_context (); p = cfun->language; - cfun->language = NULL; + + /* When -Wunused-local-typedefs is in effect, cfun->languages is + used to store data throughout the life time of the current cfun, + So don't deallocate it. */ + if (!warn_unused_local_typedefs) + cfun->language = NULL; if (DECL_STRUCT_FUNCTION (current_function_decl) == 0 && DECL_SAVED_TREE (current_function_decl) == NULL_TREE) @@ -8620,6 +8627,7 @@ c_pop_function_context (void) } c_stmt_tree = p->base.x_stmt_tree; + p->base.x_stmt_tree.x_cur_stmt_list = NULL; c_break_label = p->x_break_label; c_cont_label = p->x_cont_label; c_switch_stack = p->x_switch_stack; |