* 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.
From-SVN: r173422
+2011-05-05 Joseph Myers <joseph@codesourcery.com>
+
+ * 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.
+
2011-05-05 Michael Hope <michael.hope@linaro.org>
PR pch/45979
/* 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.
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))
{
}
}
-/* 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);
}
/* 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);
}
}
-/* 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.
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);
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. */
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 ();
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;
}
\f
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.
+2011-05-05 Joseph Myers <joseph@codesourcery.com>
+
+ * c-objc.h (objc_start_method_definition): Update prototype.
+ * stub-objc.c (objc_start_method_definition): Add extra parameter.
+
2011-05-04 Nathan Froyd <froydnj@codesourcery.com>
* c-common.c (check_main_parameter_types): Reindent. Don't use
/* Definitions of Objective-C front-end entry points used for C and C++.
Copyright (C) 1987, 1993, 1994, 1995, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
+ 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc.
This file is part of GCC.
extern void objc_set_visibility (objc_ivar_visibility_kind);
extern tree objc_build_method_signature (bool, tree, tree, tree, bool);
extern void objc_add_method_declaration (bool, tree, tree);
-extern bool objc_start_method_definition (bool, tree, tree);
+extern bool objc_start_method_definition (bool, tree, tree, tree);
extern void objc_finish_method_definition (tree);
extern void objc_add_instance_variable (tree);
extern tree objc_build_keyword_decl (tree, tree, tree, tree);
that are called from within the C and C++ front-ends,
respectively.
Copyright (C) 1991, 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
- 2004, 2005, 2007, 2009, 2010 Free Software Foundation, Inc.
+ 2004, 2005, 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
This file is part of GCC.
bool
objc_start_method_definition (bool ARG_UNUSED (is_class_method),
tree ARG_UNUSED (signature),
- tree ARG_UNUSED (attributes))
+ tree ARG_UNUSED (attributes),
+ tree ARG_UNUSED (expr))
{
return true;
}
bool,
struct c_declarator *);
static struct c_arg_info *c_parser_parms_declarator (c_parser *, bool, tree);
-static struct c_arg_info *c_parser_parms_list_declarator (c_parser *, tree);
+static struct c_arg_info *c_parser_parms_list_declarator (c_parser *, tree,
+ tree);
static struct c_parm *c_parser_parameter_declaration (c_parser *, tree);
static tree c_parser_simple_asm_expr (c_parser *);
static tree c_parser_attributes (c_parser *);
static void c_parser_objc_method_definition (c_parser *);
static void c_parser_objc_methodprotolist (c_parser *);
static void c_parser_objc_methodproto (c_parser *);
-static tree c_parser_objc_method_decl (c_parser *, bool, tree *);
+static tree c_parser_objc_method_decl (c_parser *, bool, tree *, tree *);
static tree c_parser_objc_type_name (c_parser *);
static tree c_parser_objc_protocol_refs (c_parser *);
static void c_parser_objc_try_catch_finally_statement (c_parser *);
}
else
{
- struct c_arg_info *ret = c_parser_parms_list_declarator (parser, attrs);
+ struct c_arg_info *ret = c_parser_parms_list_declarator (parser, attrs,
+ NULL);
pop_scope ();
return ret;
}
/* Parse a parameter list (possibly empty), including the closing
parenthesis but not the opening one. ATTRS are the attributes at
- the start of the list. */
+ the start of the list. EXPR is NULL or an expression that needs to
+ be evaluated for the side effects of array size expressions in the
+ parameters. */
static struct c_arg_info *
-c_parser_parms_list_declarator (c_parser *parser, tree attrs)
+c_parser_parms_list_declarator (c_parser *parser, tree attrs, tree expr)
{
bool bad_parm = false;
+
/* ??? Following the old parser, forward parameter declarations may
use abstract declarators, and if no real parameter declarations
follow the forward declarations then this is not diagnosed. Also
if (parm == NULL)
bad_parm = true;
else
- push_parm_decl (parm);
+ push_parm_decl (parm, &expr);
if (c_parser_next_token_is (parser, CPP_SEMICOLON))
{
tree new_attrs;
c_parser_consume_token (parser);
mark_forward_parm_decls ();
new_attrs = c_parser_attributes (parser);
- return c_parser_parms_list_declarator (parser, new_attrs);
+ return c_parser_parms_list_declarator (parser, new_attrs, expr);
}
if (c_parser_next_token_is (parser, CPP_CLOSE_PAREN))
{
c_parser_consume_token (parser);
if (bad_parm)
- {
- get_pending_sizes ();
- return NULL;
- }
+ return NULL;
else
- return get_parm_info (false);
+ return get_parm_info (false, expr);
}
if (!c_parser_require (parser, CPP_COMMA,
"expected %<;%>, %<,%> or %<)%>"))
{
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN, NULL);
- get_pending_sizes ();
return NULL;
}
if (c_parser_next_token_is (parser, CPP_ELLIPSIS))
{
c_parser_consume_token (parser);
if (bad_parm)
- {
- get_pending_sizes ();
- return NULL;
- }
+ return NULL;
else
- return get_parm_info (true);
+ return get_parm_info (true, expr);
}
else
{
c_parser_skip_until_found (parser, CPP_CLOSE_PAREN,
"expected %<)%>");
- get_pending_sizes ();
return NULL;
}
}
c_parser_objc_method_definition (c_parser *parser)
{
bool is_class_method = c_parser_objc_method_type (parser);
- tree decl, attributes = NULL_TREE;
+ tree decl, attributes = NULL_TREE, expr = NULL_TREE;
parser->objc_pq_context = true;
- decl = c_parser_objc_method_decl (parser, is_class_method, &attributes);
+ decl = c_parser_objc_method_decl (parser, is_class_method, &attributes,
+ &expr);
if (decl == error_mark_node)
return; /* Bail here. */
}
parser->objc_pq_context = false;
- if (objc_start_method_definition (is_class_method, decl, attributes))
+ if (objc_start_method_definition (is_class_method, decl, attributes, expr))
{
add_stmt (c_parser_compound_statement (parser));
objc_finish_method_definition (current_function_decl);
/* Remember protocol qualifiers in prototypes. */
parser->objc_pq_context = true;
- decl = c_parser_objc_method_decl (parser, is_class_method, &attributes);
+ decl = c_parser_objc_method_decl (parser, is_class_method, &attributes,
+ NULL);
/* Forget protocol qualifiers now. */
parser->objc_pq_context = false;
*/
static tree
-c_parser_objc_method_decl (c_parser *parser, bool is_class_method, tree *attributes)
+c_parser_objc_method_decl (c_parser *parser, bool is_class_method,
+ tree *attributes, tree *expr)
{
tree type = NULL_TREE;
tree sel;
if (parm == NULL)
break;
parms = chainon (parms,
- build_tree_list (NULL_TREE, grokparm (parm)));
+ build_tree_list (NULL_TREE, grokparm (parm, expr)));
}
sel = list;
}
if (parm == NULL)
parameter_declaration = error_mark_node;
else
- parameter_declaration = grokparm (parm);
+ parameter_declaration = grokparm (parm, NULL);
}
if (seen_open_paren)
c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>");
/* Definitions for C parsing and type checking.
Copyright (C) 1987, 1993, 1994, 1995, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
+ 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc.
This file is part of GCC.
/* A list of non-parameter decls (notably enumeration constants)
defined with the parameters. */
tree others;
- /* A VEC of VLA sizes from the parameters. In a function
- definition, these are used to ensure that side-effects in sizes
- of arrays converted to pointers (such as a parameter int i[n++])
- take place; otherwise, they are ignored. */
- VEC(tree,gc) *pending_sizes;
+ /* A compound expression of VLA sizes from the parameters, or NULL.
+ In a function definition, these are used to ensure that
+ side-effects in sizes of arrays converted to pointers (such as a
+ parameter int i[n++]) take place; otherwise, they are
+ ignored. */
+ tree pending_sizes;
/* True when these arguments had [*]. */
BOOL_BITFIELD had_vla_unspec : 1;
};
extern tree finish_struct (location_t, tree, tree, tree,
struct c_struct_parse_info *);
extern struct c_arg_info *build_arg_info (void);
-extern struct c_arg_info *get_parm_info (bool);
+extern struct c_arg_info *get_parm_info (bool, tree);
extern tree grokfield (location_t, struct c_declarator *,
struct c_declspecs *, tree, tree *);
extern tree groktypename (struct c_type_name *, tree *, bool *);
-extern tree grokparm (const struct c_parm *);
+extern tree grokparm (const struct c_parm *, tree *);
extern tree implicitly_declare (location_t, tree);
extern void keep_next_level (void);
extern void pending_xref_error (void);
extern void c_push_function_context (void);
extern void c_pop_function_context (void);
-extern void push_parm_decl (const struct c_parm *);
+extern void push_parm_decl (const struct c_parm *, tree *);
extern struct c_declarator *set_array_declarator_inner (struct c_declarator *,
struct c_declarator *);
extern tree c_builtin_function (tree);
+2011-05-05 Joseph Myers <joseph@codesourcery.com>
+
+ * parser.c (cp_parser_objc_method_definition_list): Update call to
+ objc_start_method_definition.
+
2011-05-04 Jason Merrill <jason@redhat.com>
PR c++/48749
token = cp_lexer_peek_token (parser->lexer);
continue;
}
- objc_start_method_definition (is_class_method, sig, attribute);
+ objc_start_method_definition (is_class_method, sig, attribute,
+ NULL_TREE);
/* For historical reasons, we accept an optional semicolon. */
if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON))
+2011-05-05 Joseph Myers <joseph@codesourcery.com>
+
+ * 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.
+
2011-04-26 Jason Merrill <jason@redhat.com>
* objc-act.c (objc_fold_objc_type_ref): Remove.
static tree start_class (enum tree_code, tree, tree, tree, tree);
static tree continue_class (tree);
static void finish_class (tree);
-static void start_method_def (tree);
+static void start_method_def (tree, tree);
static tree start_protocol (enum tree_code, tree, tree, tree);
static tree build_method_decl (enum tree_code, tree, tree, tree, bool);
/* Return 'true' if the method definition could be started, and
'false' if not (because we are outside an @implementation context).
+ EXPR is NULL or an expression that needs to be evaluated for the
+ side effects of array size expressions in the parameters.
*/
bool
-objc_start_method_definition (bool is_class_method, tree decl, tree attributes)
+objc_start_method_definition (bool is_class_method, tree decl, tree attributes,
+ tree expr)
{
if (!objc_implementation_context)
{
decl,
is_class_method,
/* is optional */ false);
- start_method_def (decl);
+ start_method_def (decl, expr);
return true;
}
? TAG_CXX_DESTRUCT
: TAG_CXX_CONSTRUCT),
make_node (TREE_LIST),
- false), NULL);
+ false), NULL, NULL_TREE);
body = begin_function_body ();
compound_stmt = begin_compound_stmt (0);
decl = copy_node (decl);
DECL_SOURCE_LOCATION (decl) = location;
- objc_start_method_definition (false /* is_class_method */, decl, NULL_TREE);
+ objc_start_method_definition (false /* is_class_method */, decl, NULL_TREE,
+ NULL_TREE);
body = c_begin_compound_stmt (true);
/* Now we need to decide how we build the getter. There are three
decl = copy_node (decl);
DECL_SOURCE_LOCATION (decl) = DECL_SOURCE_LOCATION (property);
- objc_start_method_definition (false /* is_class_method */, decl, NULL_TREE);
+ objc_start_method_definition (false /* is_class_method */, decl, NULL_TREE,
+ NULL_TREE);
body = c_begin_compound_stmt (true);
#ifdef OBJCPLUS
tree
-objc_get_parm_info (int have_ellipsis ATTRIBUTE_UNUSED)
+objc_get_parm_info (int have_ellipsis ATTRIBUTE_UNUSED,
+ tree expr ATTRIBUTE_UNUSED)
{
tree parm_info = objc_parmlist;
objc_parmlist = NULL_TREE;
}
#else
struct c_arg_info *
-objc_get_parm_info (int have_ellipsis)
+objc_get_parm_info (int have_ellipsis, tree expr)
{
tree parm_info = objc_parmlist;
struct c_arg_info *arg_info;
finish_decl (parm_info, input_location, NULL_TREE, NULL_TREE, NULL_TREE);
parm_info = next;
}
- arg_info = get_parm_info (have_ellipsis);
+ arg_info = get_parm_info (have_ellipsis, expr);
pop_scope ();
objc_parmlist = NULL_TREE;
return arg_info;
/* Transform an Objective-C method definition into a static C function
definition, synthesizing the first two arguments, "self" and "_cmd",
- in the process. */
+ in the process. EXPR is NULL or an expression that needs to be
+ evaluated for the side effects of array size expressions in the
+ parameters. */
static void
-start_method_def (tree method)
+start_method_def (tree method, tree expr)
{
tree parmlist;
#ifdef OBJCPLUS
have_ellipsis = 1;
}
- parm_info = objc_get_parm_info (have_ellipsis);
+ parm_info = objc_get_parm_info (have_ellipsis, expr);
really_start_method (objc_method_context, parm_info);
}
#else
objc_start_function (get_identifier (TAG_GNUINIT),
build_function_type_list (void_type_node, NULL_TREE),
- NULL_TREE, objc_get_parm_info (0));
+ NULL_TREE, objc_get_parm_info (0, NULL_TREE));
#endif
body = c_begin_compound_stmt (true);
add_stmt (build_function_call
#ifdef OBJCPLUS
extern void objc_start_function (tree, tree, tree, tree);
-extern tree objc_get_parm_info (int);
+extern tree objc_get_parm_info (int, tree);
#else
extern void objc_start_function (tree, tree, tree, struct c_arg_info *);
-extern struct c_arg_info *objc_get_parm_info (int);
+extern struct c_arg_info *objc_get_parm_info (int, tree);
#endif
extern void objc_push_parm (tree);
extern tree get_arg_type_list (tree, int, int);