aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/init.c
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2004-06-22 07:18:38 +0000
committerMark Mitchell <mark@codesourcery.com>2004-06-22 07:18:38 +0000
commitd3ab2f90db5346f4f07ff7a61c2882eff8e625a4 (patch)
tree7c02283f18d2310094c350da6ada68b06b88aa56 /gcc/cp/init.c
parent78f0456d78547df4a98b0003d7af279e0ac33fa4 (diff)
* cp-tree.def (NEW_EXPR): Add a fourth slot.
* cp-tree.h (PARMLIST_ELLIPSIS_P): Remove. (TREE_PARMLIST): Likewise. (CALL_DECLARATOR_PARMS): Likewise. (CALL_DECLARATOR_QUALS): Likewise. (CALL_DECLARATOR_EXCEPTION_SPEC): Likewise. (cp_declarator_kind): New type. (cp_parameter_declarator): Likewise. (cp_declarator): Likewise. (cp_error_declarator): Likewise. (no_parameters): Likewise. (groktypename): Change prototype. (start_decl): Likewise. (start_handler_parms): Likewise. (get_scope_of_declarator): Likewise. (start_function): Likewise. (start_preparsed_function): New function. (start_function): Change prototype. (start_method): Likewise. (grokfield): Likewise. (grokbitfield): Likewise. (build_new): Likewise. (make_pointer_declarator): Remove. (make_reference_declarator): Likewise. (make_call_declarator): Likewise. (set_quals_and_spec): Likewise. (process_template_parm): Change prototype. (begin_function_definition): Remove. (finish_parmlist): Remove. * decl.c (groktypename): Do not use trees to represent declarators. (start_decl): Likewise. (start_handler_parms): Remove. (get_scope_of_declarator): Reimplement. (grokdeclarator): Do not use trees to represent declarators. (grokparms): Likewise. (start_function): Likewise. (start_method): Likewise. (build_void_list_mode): Do not use TREE_PARMLIST. * decl.h (grokdeclarator): Change prototype. * decl2.c (grok_method_quals): Robustify. (grok_x_components): Do not use trees to represent declarators. (grokfield): Likewise. (grokbitfield): Likewise. (start_objects): Build FUNCTION_DECLs, not declarators. (start_static_storage_duration_function): Likewise. * init.c (build_new): Simplify. * lex.c (make_pointer_declarator): Remove. (make_reference_declarator): Likewise. (make_call_declarator): Likewise. (set_quals_and_spec): Likewise. * method.c (use_thunk): Use start_preparsed_function. (synthesize_method): Likewise. (implicitly_declare_fn): Build FUNCTION_DECLs, not declarators. * optimize.c (maybe_clone_body): Use start_preparsed_function. * parser.c (cp_error_declarator): New variable. (declarator_obstack): Likewise. (alloc_declarator): New function. (make_declarator): Likewise. (make_id_declarator): Likewise. (make_pointer_declarator): Likewise. (make_reference_declarator): Likewise. (make_ptrmem_declarator): Likewise. (make_call_declarator): Likewise. (make_array_declarator): Likewise. (no_parameters): New variable. (make_parameter_declarator): Likewise. (cp_parser_check_for_definition_in_return_type): Do not use trees to represent declarators. (cp_parser_translation_unit): Likewise. (cp_parser_new_expression): Likewise. (cp_parser_new_type_id): Likewise. (cp_parser_new_declarator_opt): Likewise. (cp_parser_direct_new_declarator): Likewise. (cp_parser_condition): Likewise. (cp_parser_declaration_statement): Likewise. (cp_parser_declaration): Likewise. (cp_parser_conversion_type_id): Likewise. (cp_parser_conversion_declarator_opt): Likewise. (cp_parser_template_parameter_list): Likewise. (cp_parser_template_parameter): Likewise. (cp_parser_explicit_instantiation): Likewise. (cp_parser_init_declarator): Likewise. (cp_parser_declarator): Likewise. (cp_parser_direct_declarator): Likewise. (cp_parser_type_id): Likewise. (cp_parser_parameter_declaration_clause): Likewise. (cp_parser_parameter_declaration_list): Likewise. (cp_parser_parameter_declaration): Likewise. (cp_parser_member_declaration): Likewise. (cp_parser_exception_declaration): Likewise. (cp_parser_check_declarator_template_parameters): Likewise. (cp_parser_function_definition_from_specifiers_and_declarator): Likewise. (cp_parser_save_member_function_body): Likewise. * pt.c (process_template_parm): Add is_non_type parameter. (convert_template_argument): Adjust call to groktypename. (tsubst_call_declarator_parms): Remove use of TREE_PARMLIST. (tsubst): Do not expect declarators. (tsubst_copy_and_build): Adjust NEW_EXPR case to handle additional argument. (instantiate_decl): Use start_preparsed_function. * semantics.c (begin_function_definition): Remove. (finish_parmlist): Remove. * cp-mudflap.c (mflang_flush_calls): Build FUNCTION_DECLs, not declarators. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@83482 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/init.c')
-rw-r--r--gcc/cp/init.c145
1 files changed, 11 insertions, 134 deletions
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 2af51185e7b..c2a98781431 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -1665,126 +1665,18 @@ build_builtin_delete_call (tree addr)
PLACEMENT is the `placement' list for user-defined operator new (). */
tree
-build_new (tree placement, tree decl, tree init, int use_global_new)
+build_new (tree placement, tree type, tree nelts, tree init,
+ int use_global_new)
{
- tree type, rval;
- tree nelts = NULL_TREE, t;
- int has_array = 0;
+ tree rval;
- if (decl == error_mark_node)
+ if (type == error_mark_node)
return error_mark_node;
- if (TREE_CODE (decl) == TREE_LIST)
- {
- tree absdcl = TREE_VALUE (decl);
- tree last_absdcl = NULL_TREE;
-
- if (current_function_decl
- && DECL_CONSTRUCTOR_P (current_function_decl))
- my_friendly_assert (immediate_size_expand == 0, 19990926);
-
- nelts = integer_one_node;
-
- if (absdcl && TREE_CODE (absdcl) == CALL_EXPR)
- abort ();
- while (absdcl && TREE_CODE (absdcl) == INDIRECT_REF)
- {
- last_absdcl = absdcl;
- absdcl = TREE_OPERAND (absdcl, 0);
- }
-
- if (absdcl && TREE_CODE (absdcl) == ARRAY_REF)
- {
- /* Probably meant to be a vec new. */
- tree this_nelts;
-
- while (TREE_OPERAND (absdcl, 0)
- && TREE_CODE (TREE_OPERAND (absdcl, 0)) == ARRAY_REF)
- {
- last_absdcl = absdcl;
- absdcl = TREE_OPERAND (absdcl, 0);
- }
-
- has_array = 1;
- this_nelts = TREE_OPERAND (absdcl, 1);
- if (this_nelts != error_mark_node)
- {
- if (this_nelts == NULL_TREE)
- error ("new of array type fails to specify size");
- else if (processing_template_decl)
- {
- nelts = this_nelts;
- absdcl = TREE_OPERAND (absdcl, 0);
- }
- else
- {
- if (build_expr_type_conversion (WANT_INT | WANT_ENUM,
- this_nelts, false)
- == NULL_TREE)
- pedwarn ("size in array new must have integral type");
-
- this_nelts = save_expr (cp_convert (sizetype, this_nelts));
- absdcl = TREE_OPERAND (absdcl, 0);
- if (this_nelts == integer_zero_node)
- {
- warning ("zero size array reserves no space");
- nelts = integer_zero_node;
- }
- else
- nelts = cp_build_binary_op (MULT_EXPR, nelts, this_nelts);
- }
- }
- else
- nelts = integer_zero_node;
- }
-
- if (last_absdcl)
- TREE_OPERAND (last_absdcl, 0) = absdcl;
- else
- TREE_VALUE (decl) = absdcl;
-
- type = groktypename (decl);
- if (! type || type == error_mark_node)
- return error_mark_node;
- }
- else if (TREE_CODE (decl) == IDENTIFIER_NODE)
- {
- if (IDENTIFIER_HAS_TYPE_VALUE (decl))
- {
- /* An aggregate type. */
- type = IDENTIFIER_TYPE_VALUE (decl);
- decl = TYPE_MAIN_DECL (type);
- }
- else
- {
- /* A builtin type. */
- decl = lookup_name (decl, 1);
- my_friendly_assert (TREE_CODE (decl) == TYPE_DECL, 215);
- type = TREE_TYPE (decl);
- }
- }
- else if (TREE_CODE (decl) == TYPE_DECL)
- {
- type = TREE_TYPE (decl);
- }
- else
- {
- type = decl;
- decl = TYPE_MAIN_DECL (type);
- }
-
if (processing_template_decl)
{
- if (has_array)
- t = tree_cons (tree_cons (NULL_TREE, type, NULL_TREE),
- build_min_nt (ARRAY_REF, NULL_TREE, nelts,
- NULL_TREE, NULL_TREE),
- NULL_TREE);
- else
- t = type;
-
rval = build_min (NEW_EXPR, build_pointer_type (type),
- placement, t, init);
+ placement, type, nelts, init);
NEW_EXPR_USE_GLOBAL (rval) = use_global_new;
TREE_SIDE_EFFECTS (rval) = 1;
return rval;
@@ -1805,22 +1697,8 @@ build_new (tree placement, tree decl, tree init, int use_global_new)
return error_mark_node;
}
- /* When the object being created is an array, the new-expression yields a
- pointer to the initial element (if any) of the array. For example,
- both new int and new int[10] return an int*. 5.3.4. */
- if (TREE_CODE (type) == ARRAY_TYPE && has_array == 0)
- {
- nelts = array_type_nelts_top (type);
- has_array = 1;
- type = TREE_TYPE (type);
- }
-
- if (has_array)
- t = build_nt (ARRAY_REF, type, nelts, NULL_TREE, NULL_TREE);
- else
- t = type;
-
- rval = build (NEW_EXPR, build_pointer_type (type), placement, t, init);
+ rval = build (NEW_EXPR, build_pointer_type (type), placement, type,
+ nelts, init);
NEW_EXPR_USE_GLOBAL (rval) = use_global_new;
TREE_SIDE_EFFECTS (rval) = 1;
rval = build_new_1 (rval);
@@ -1957,15 +1835,14 @@ build_new_1 (tree exp)
placement = TREE_OPERAND (exp, 0);
type = TREE_OPERAND (exp, 1);
- init = TREE_OPERAND (exp, 2);
+ nelts = TREE_OPERAND (exp, 2);
+ init = TREE_OPERAND (exp, 3);
globally_qualified_p = NEW_EXPR_USE_GLOBAL (exp);
- if (TREE_CODE (type) == ARRAY_REF)
+ if (nelts)
{
has_array = 1;
- nelts = outer_nelts = TREE_OPERAND (type, 1);
- type = TREE_OPERAND (type, 0);
-
+ outer_nelts = nelts;
/* Use an incomplete array type to avoid VLA headaches. */
full_type = build_cplus_array_type (type, NULL_TREE);
}