From 90a898163f77df9a40512d9639a0d209353ccf6b Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Fri, 2 Sep 2005 12:34:58 +0000 Subject: [PATCH] re PR c/22061 (internal compiler error: in find_function_data, at function.c:317) PR c/22061 * c-decl.c (push_parm_decl): Push and pop x_dont_save_pending_sizes_p around the call to grokdeclarator. Call grokdeclarator with the field set to 0. (store_parm_decls): Always store the pending_sizes in cfun. (c_expand_body_1): Call put_pending_sizes. * c-objc-common.c (c_cannot_inline_tree_fn): Always check pending_sizes. From-SVN: r103776 --- gcc/ChangeLog | 11 +++++++++++ gcc/c-decl.c | 44 ++++++++++++++++++----------------------- gcc/c-objc-common.c | 15 +++++--------- gcc/testsuite/ChangeLog | 8 ++++++++ 4 files changed, 43 insertions(+), 35 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e815b00a583d..187e883d8b48 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2005-09-02 Richard Sandiford + + PR c/22061 + * c-decl.c (push_parm_decl): Push and pop x_dont_save_pending_sizes_p + around the call to grokdeclarator. Call grokdeclarator with the + field set to 0. + (store_parm_decls): Always store the pending_sizes in cfun. + (c_expand_body_1): Call put_pending_sizes. + * c-objc-common.c (c_cannot_inline_tree_fn): Always check + pending_sizes. + 2005-09-01 Jakub Jelinek PR rtl-optimization/23478 diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 38166cc94f39..b4d7e357ea6b 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -2960,12 +2960,21 @@ void push_parm_decl (tree parm) { tree decl; + int old_dont_save_pending_sizes_p = 0; /* Don't attempt to expand sizes while parsing this decl. (We can get here with i_s_e 1 somehow from Objective-C.) */ int save_immediate_size_expand = immediate_size_expand; immediate_size_expand = 0; + /* If this is a nested function, we do want to keep SAVE_EXPRs for + the argument sizes, regardless of the parent's setting. */ + if (cfun) + { + old_dont_save_pending_sizes_p = cfun->x_dont_save_pending_sizes_p; + cfun->x_dont_save_pending_sizes_p = 0; + } + decl = grokdeclarator (TREE_VALUE (TREE_PURPOSE (parm)), TREE_PURPOSE (TREE_PURPOSE (parm)), PARM, 0, NULL); @@ -2975,6 +2984,8 @@ push_parm_decl (tree parm) finish_decl (decl, NULL_TREE, NULL_TREE); + if (cfun) + cfun->x_dont_save_pending_sizes_p = old_dont_save_pending_sizes_p; immediate_size_expand = save_immediate_size_expand; } @@ -5990,9 +6001,6 @@ store_parm_decls (void) { tree fndecl = current_function_decl; - /* The function containing FNDECL, if any. */ - tree context = decl_function_context (fndecl); - /* True if this definition is written with a prototype. */ bool prototype = (current_function_parms && TREE_CODE (current_function_parms) != TREE_LIST); @@ -6017,20 +6025,9 @@ store_parm_decls (void) /* Begin the statement tree for this function. */ begin_stmt_tree (&DECL_SAVED_TREE (fndecl)); - /* If this is a nested function, save away the sizes of any - variable-size types so that we can expand them when generating - RTL. */ - if (context) - { - tree t; - - DECL_LANG_SPECIFIC (fndecl)->pending_sizes - = nreverse (get_pending_sizes ()); - for (t = DECL_LANG_SPECIFIC (fndecl)->pending_sizes; - t; - t = TREE_CHAIN (t)) - SAVE_EXPR_CONTEXT (TREE_VALUE (t)) = context; - } + /* Save away the sizes of any variable-size types so that we can + expand them when generating RTL. */ + DECL_LANG_SPECIFIC (fndecl)->pending_sizes = get_pending_sizes (); /* This function is being processed in whole-function mode. */ cfun->x_whole_function_mode_p = 1; @@ -6181,15 +6178,12 @@ static void c_expand_body_1 (tree fndecl, int nested_p) { if (nested_p) - { - /* Make sure that we will evaluate variable-sized types involved - in our function's type. */ - expand_pending_sizes (DECL_LANG_SPECIFIC (fndecl)->pending_sizes); - - /* Squirrel away our current state. */ - push_function_context (); - } + /* Squirrel away our current state. */ + push_function_context (); + /* Make sure that we will evaluate variable-sized types involved + in our function's type. */ + put_pending_sizes (DECL_LANG_SPECIFIC (fndecl)->pending_sizes); tree_rest_of_compilation (fndecl, nested_p); if (nested_p) diff --git a/gcc/c-objc-common.c b/gcc/c-objc-common.c index fe0c0d5b9337..0efa2adc3725 100644 --- a/gcc/c-objc-common.c +++ b/gcc/c-objc-common.c @@ -118,17 +118,12 @@ c_cannot_inline_tree_fn (tree *fnp) } } - if (! DECL_FILE_SCOPE_P (fn)) + if (DECL_LANG_SPECIFIC (fn)->pending_sizes) { - /* If a nested function has pending sizes, we may have already - saved them. */ - if (DECL_LANG_SPECIFIC (fn)->pending_sizes) - { - if (do_warning) - warning ("%Jnested function '%F' can never be inlined because it " - "has possibly saved pending sizes", fn, fn); - goto cannot_inline; - } + if (do_warning) + warning ("%Jfunction '%F' can never be inlined because it has " + "pending sizes", fn, fn); + goto cannot_inline; } return 0; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c043043e9ec7..c1e664f64ce1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2005-09-02 Richard Sandiford + + PR c/22061 + * gcc.c-torture/execute/pr22061-1.c, + * gcc.c-torture/execute/pr22061-2.c, + * gcc.c-torture/execute/pr22061-3.c, + * gcc.c-torture/execute/pr22061-4.c: New tests. + 2005-09-02 Volker Reichelt PR c++/22233 -- 2.47.2