/* Nonzero if the user wrote `::new' rather than just `new'. */
int globally_qualified_p;
int use_java_new = 0;
- bool check_cookie = false;
/* If non-NULL, the number of extra bytes to allocate at the
beginning of the storage allocated for an array-new expression in
order to store the number of elements. */
else
{
/* Use a global operator new. */
- /* Create the argument list. */
- args = tree_cons (NULL_TREE, size, placement);
- /* Call the function. */
- alloc_call
- = build_new_function_call (lookup_function_nonclass (fnname, args),
- args);
- /* We may need to add a cookie. */
- check_cookie = true;
+ /* See if a cookie might be required. */
+ if (has_array && TYPE_VEC_NEW_USES_COOKIE (true_type))
+ cookie_size = get_cookie_size (true_type);
+ else
+ cookie_size = NULL_TREE;
+
+ alloc_call = build_operator_new_call (fnname, placement,
+ &size, &cookie_size);
}
}
alloc_fn = get_callee_fndecl (t);
my_friendly_assert (alloc_fn != NULL_TREE, 20020325);
- /* If we postponed deciding whether or not to use a cookie until
- after we knew what function was being called, that time is
- now. */
- if (check_cookie)
- {
- /* If a cookie is required, add some extra space. Whether
- or not a cookie is required cannot be determined until
- after we know which function was called. */
- if (has_array && TYPE_VEC_NEW_USES_COOKIE (true_type))
- {
- bool use_cookie = true;
- if (!abi_version_at_least (2))
- {
- /* In G++ 3.2, the check was implemented incorrectly; it
- looked at the placement expression, rather than the
- type of the function. */
- if (placement && !TREE_CHAIN (placement)
- && same_type_p (TREE_TYPE (TREE_VALUE (placement)),
- ptr_type_node))
- use_cookie = false;
- }
- else
- {
- tree arg_types;
-
- arg_types = TYPE_ARG_TYPES (TREE_TYPE (alloc_fn));
- /* Skip the size_t parameter. */
- arg_types = TREE_CHAIN (arg_types);
- /* Check the remaining parameters (if any). */
- if (arg_types
- && !TREE_CHAIN (arg_types)
- && same_type_p (TREE_TYPE (TREE_VALUE (arg_types)),
- ptr_type_node))
- use_cookie = false;
- }
- /* If we need a cookie, adjust the number of bytes allocated. */
- if (use_cookie)
- {
- cookie_size = get_cookie_size (true_type);
- size = size_binop (PLUS_EXPR, size, cookie_size);
- /* Update the argument list to reflect the adjusted size. */
- TREE_VALUE (args) = cookie_size;
- }
- }
- }
-
/* Now, check to see if this function is actually a placement
allocation function. This can happen even when PLACEMENT is NULL
because we might have something like: