diff options
author | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-05-05 10:20:31 +0000 |
---|---|---|
committer | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-05-05 10:20:31 +0000 |
commit | 4232a958fa71dc57b9f59004eec728201da3c8a3 (patch) | |
tree | b17a45e382a8a322480a5f68a04bd1948915571e /gcc/c-decl.c | |
parent | c275616e996d6688e2792e2d31fac113d2a186e1 (diff) | |
download | ppe42-gcc-4232a958fa71dc57b9f59004eec728201da3c8a3.tar.gz ppe42-gcc-4232a958fa71dc57b9f59004eec728201da3c8a3.zip |
* c-decl.c (finish_decl): Don't call get_pending_sizes.
(grokparm): Add parameter expr. Pass it to grokdeclarator.
(push_parm_decl): Add parameter expr. Pass it to grokdeclarator.
(c_variable_size): Remove.
(grokdeclarator): Use save_expr instead of c_variable_size. Don't
call put_pending_sizes.
(get_parm_info): Add parameter expr. Use it to set
arg_info->pending_sizes.
(store_parm_decls): Use arg_info->pending_sizes instead or calling
get_pending_sizes.
* c-parser.c (c_parser_parms_declarator): Update call to
c_parser_parms_list_declarator.
(c_parser_parms_list_declarator): Take parameter expr. Update
call to push_parm_decl. Update recursive call. Don't call
get_pending_sizes. Update calls to get_parm_info.
(c_parser_objc_method_definition): Update calls to
c_parser_objc_method_decl and objc_start_method_definition.
(c_parser_objc_methodproto): Update call to
c_parser_objc_method_decl.
(c_parser_objc_method_decl): Add parameter expr. Update call to
grokparm.
(c_parser_objc_try_catch_finally_statement): Update call to
grokparm.
* c-tree.h (struct c_arg_info.pending_sizes): Change to a tree.
(get_parm_info, grokparm, push_parm_decl): Update prototypes.
c-family:
* c-objc.h (objc_start_method_definition): Update prototype.
* stub-objc.c (objc_start_method_definition): Add extra parameter.
cp:
* parser.c (cp_parser_objc_method_definition_list): Update call to
objc_start_method_definition.
objc:
* objc-act.c (objc_start_method_definition): Add parameter expr.
Update call to start_method_def.
(objc_generate_cxx_ctor_or_dtor, objc_synthesize_getter,
objc_synthesize_setter) Update calls to
objc_start_method_definition.
(objc_get_parm_info): Add parameter expr. Update call to
get_parm_info.
(start_method_def): Add parameter expr. Update call to
objc_get_parm_info.
* objc-gnu-runtime-abi-01.c (build_module_initializer_routine):
Update call to objc_get_parm_info.
* objc-runtime-shared-support.h (objc_get_parm_info): Add extra
parameter.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@173422 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r-- | gcc/c-decl.c | 76 |
1 files changed, 21 insertions, 55 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 9b217d26de5..6bc09489214 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -1,6 +1,6 @@ /* Process declarations and variables for C compiler. Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, - 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 + 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. This file is part of GCC. @@ -4428,12 +4428,6 @@ finish_decl (tree decl, location_t init_loc, tree init, rest_of_decl_compilation (decl, DECL_FILE_SCOPE_P (decl), 0); } - /* At the end of a declaration, throw away any variable type sizes - of types defined inside that declaration. There is no use - computing them in the following function definition. */ - if (current_scope == file_scope) - get_pending_sizes (); - /* Install a cleanup (aka destructor) if one was given. */ if (TREE_CODE (decl) == VAR_DECL && !TREE_STATIC (decl)) { @@ -4478,14 +4472,17 @@ finish_decl (tree decl, location_t init_loc, tree init, } } -/* Given a parsed parameter declaration, decode it into a PARM_DECL. */ +/* Given a parsed parameter declaration, decode it into a PARM_DECL. + EXPR is NULL or a pointer to an expression that needs to be + evaluated for the side effects of array size expressions in the + parameters. */ tree -grokparm (const struct c_parm *parm) +grokparm (const struct c_parm *parm, tree *expr) { tree attrs = parm->attrs; tree decl = grokdeclarator (parm->declarator, parm->specs, PARM, false, - NULL, &attrs, NULL, NULL, DEPRECATED_NORMAL); + NULL, &attrs, expr, NULL, DEPRECATED_NORMAL); decl_attributes (&decl, attrs, 0); @@ -4493,16 +4490,18 @@ grokparm (const struct c_parm *parm) } /* Given a parsed parameter declaration, decode it into a PARM_DECL - and push that on the current scope. */ + and push that on the current scope. EXPR is a pointer to an + expression that needs to be evaluated for the side effects of array + size expressions in the parameters. */ void -push_parm_decl (const struct c_parm *parm) +push_parm_decl (const struct c_parm *parm, tree *expr) { tree attrs = parm->attrs; tree decl; decl = grokdeclarator (parm->declarator, parm->specs, PARM, false, NULL, - &attrs, NULL, NULL, DEPRECATED_NORMAL); + &attrs, expr, NULL, DEPRECATED_NORMAL); decl_attributes (&decl, attrs, 0); decl = pushdecl (decl); @@ -4789,34 +4788,6 @@ warn_variable_length_array (tree name, tree size) } } -/* Given a size SIZE that may not be a constant, return a SAVE_EXPR to - serve as the actual size-expression for a type or decl. This is - like variable_size in stor-layout.c, but we make global_bindings_p - return negative to avoid calls to that function from outside the - front end resulting in errors at file scope, then call this version - instead from front-end code. */ - -static tree -c_variable_size (tree size) -{ - tree save; - - if (TREE_CONSTANT (size)) - return size; - - size = save_expr (size); - - save = skip_simple_arithmetic (size); - - if (cfun && cfun->dont_save_pending_sizes_p) - return size; - - if (!global_bindings_p ()) - put_pending_size (save); - - return size; -} - /* Given declspecs and a declarator, determine the name and type of the object declared and construct a ..._DECL node for it. @@ -5354,7 +5325,7 @@ grokdeclarator (const struct c_declarator *declarator, MINUS_EXPR, which allows the -1 to get folded with the +1 that happens when building TYPE_SIZE. */ if (size_varies) - size = c_variable_size (size); + size = save_expr (size); if (this_size_varies && TREE_CODE (size) == INTEGER_CST) size = build2 (COMPOUND_EXPR, TREE_TYPE (size), integer_zero_node, size); @@ -5573,8 +5544,6 @@ grokdeclarator (const struct c_declarator *declarator, inner layer of declarator. */ arg_info = declarator->u.arg_info; arg_types = grokparms (arg_info, really_funcdef); - if (really_funcdef) - put_pending_sizes (arg_info->pending_sizes); /* Type qualifiers before the return type of the function qualify the return type, not the function type. */ @@ -6265,10 +6234,13 @@ build_arg_info (void) This structure is later fed to 'grokparms' and 'store_parm_decls'. ELLIPSIS being true means the argument list ended in '...' so don't - append a sentinel (void_list_node) to the end of the type-list. */ + append a sentinel (void_list_node) to the end of the type-list. + + EXPR is NULL or an expression that needs to be evaluated for the + side effects of array size expressions in the parameters. */ struct c_arg_info * -get_parm_info (bool ellipsis) +get_parm_info (bool ellipsis, tree expr) { struct c_binding *b = current_scope->bindings; struct c_arg_info *arg_info = build_arg_info (); @@ -6444,7 +6416,7 @@ get_parm_info (bool ellipsis) arg_info->tags = tags; arg_info->types = types; arg_info->others = others; - arg_info->pending_sizes = get_pending_sizes (); + arg_info->pending_sizes = expr; return arg_info; } @@ -8199,14 +8171,8 @@ store_parm_decls (void) because we throw away the array type in favor of a pointer type, and thus won't naturally see the SAVE_EXPR containing the increment. All other pending sizes would be handled by gimplify_parameters. */ - { - VEC(tree,gc) *pending_sizes = get_pending_sizes (); - tree t; - int i; - - FOR_EACH_VEC_ELT (tree, pending_sizes, i, t) - add_stmt (t); - } + if (arg_info->pending_sizes) + add_stmt (arg_info->pending_sizes); /* Even though we're inside a function body, we still don't want to call expand_expr to calculate the size of a variable-sized array. |