aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-decl.c
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2001-06-05 06:51:02 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2001-06-05 06:51:02 +0000
commit1f7317498d7f85794a0e86cf66a1b6a5a8b1dcd9 (patch)
tree44b13ffdf8f48f0846c6fa756dcb798b1402864b /gcc/c-decl.c
parent333e14b0da82d2a6f002ca385175c63df7d6050a (diff)
downloadgcc-1f7317498d7f85794a0e86cf66a1b6a5a8b1dcd9.zip
gcc-1f7317498d7f85794a0e86cf66a1b6a5a8b1dcd9.tar.gz
gcc-1f7317498d7f85794a0e86cf66a1b6a5a8b1dcd9.tar.bz2
c-tree.h (lang_decl): Add pending_sizes fields.
* c-tree.h (lang_decl): Add pending_sizes fields. * c-decl.c (store_parm_decls): Save pending_sizes away for nested functions. (c_expand_body): Expand them. (lang_mark_tree): Mark lang_decl:pending_sizes. * function.c (expand_pending_sizes): New function, broken out from ... (expand_function_start): ... here. * tree.h (expand_pending_sizes): Declare it. From-SVN: r42892
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r--gcc/c-decl.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 88a41f9..314a306 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -6167,6 +6167,9 @@ store_parm_decls ()
/* Nonzero if this definition is written with a prototype. */
int prototype = 0;
+ /* The function containing FNDECL, if any. */
+ tree context = decl_function_context (fndecl);
+
if (specparms != 0 && TREE_CODE (specparms) != TREE_LIST)
{
/* This case is when the function was defined with an ANSI prototype.
@@ -6534,14 +6537,28 @@ store_parm_decls ()
gen_aux_info_record (fndecl, 1, 0, prototype);
/* Initialize the RTL code for the function. */
-
init_function_start (fndecl, input_filename, lineno);
/* Begin the statement tree for this function. */
DECL_LANG_SPECIFIC (current_function_decl)
- =((struct lang_decl *) ggc_alloc (sizeof (struct lang_decl)));
+ =((struct lang_decl *) ggc_alloc_cleared (sizeof (struct lang_decl)));
begin_stmt_tree (&DECL_SAVED_TREE (current_function_decl));
+ /* 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;
+ }
+
/* This function is being processed in whole-function mode. */
cfun->x_whole_function_mode_p = 1;
@@ -6786,9 +6803,14 @@ c_expand_body (fndecl, nested_p)
if (flag_syntax_only)
return;
- /* Squirrel away our current state. */
if (nested_p)
- push_function_context ();
+ {
+ /* 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 ();
+ }
/* Initialize the RTL code for the function. */
current_function_decl = fndecl;
@@ -6823,7 +6845,7 @@ c_expand_body (fndecl, nested_p)
/* Allow the body of the function to be garbage collected. */
DECL_SAVED_TREE (fndecl) = NULL_TREE;
- /* We hard-wired immediate_size_expand to zero in start_function.
+ /* We hard-wired immediate_size_expand to zero above.
expand_function_end will decrement this variable. So, we set the
variable to one here, so that after the decrement it will remain
zero. */
@@ -7116,6 +7138,7 @@ lang_mark_tree (t)
{
ggc_mark (DECL_LANG_SPECIFIC (t));
c_mark_lang_decl (&DECL_LANG_SPECIFIC (t)->base);
+ ggc_mark_tree (DECL_LANG_SPECIFIC (t)->pending_sizes);
}
}