This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH for 15142
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 01 Jun 2004 16:28:20 -0400
- Subject: C++ PATCH for 15142
convert_arg_to_ellipsis was catching cases which would cause the backend to
abort, but wasn't actually changing the tree structure enough to avoid it.
Fixed thus. Thanks to Mark for the idea of dereferencing a null pointer
rather than messing with TARGET_EXPR.
Tested x86_64-pc-linux-gnu, applied to trunk. Will apply to 3.4 after it's
been tested there.
2004-06-01 Jason Merrill <jason@redhat.com>
PR c++/15142
* call.c (call_builtin_trap): Remove type parm.
(convert_arg_to_ellipsis): Change a non-POD argument to integer type.
(build_x_va_arg): Dereference a null pointer for a non-POD argument.
*** call.c.~1~ 2004-06-01 13:39:50.000000000 -0400
--- call.c 2004-06-01 13:40:20.000000000 -0400
*************** static conversion *direct_reference_bind
*** 182,188 ****
static bool promoted_arithmetic_type_p (tree);
static conversion *conditional_conversion (tree, tree);
static char *name_as_c_string (tree, tree, bool *);
! static tree call_builtin_trap (tree);
static tree prep_operand (tree);
static void add_candidates (tree, tree, tree, bool, tree, tree,
int, struct z_candidate **);
--- 182,188 ----
static bool promoted_arithmetic_type_p (tree);
static conversion *conditional_conversion (tree, tree);
static char *name_as_c_string (tree, tree, bool *);
! static tree call_builtin_trap (void);
static tree prep_operand (tree);
static void add_candidates (tree, tree, tree, bool, tree, tree,
int, struct z_candidate **);
*************** convert_like_real (conversion *convs, tr
*** 4325,4342 ****
LOOKUP_NORMAL|LOOKUP_NO_CONVERSION);
}
! /* Build a call to __builtin_trap which can be used as an expression of
! type TYPE. */
static tree
! call_builtin_trap (tree type)
{
tree fn = implicit_built_in_decls[BUILT_IN_TRAP];
my_friendly_assert (fn != NULL, 20030927);
fn = build_call (fn, NULL_TREE);
- fn = build (COMPOUND_EXPR, type, fn, error_mark_node);
- fn = force_target_expr (type, fn);
return fn;
}
--- 4325,4339 ----
LOOKUP_NORMAL|LOOKUP_NO_CONVERSION);
}
! /* Build a call to __builtin_trap. */
static tree
! call_builtin_trap (void)
{
tree fn = implicit_built_in_decls[BUILT_IN_TRAP];
my_friendly_assert (fn != NULL, 20030927);
fn = build_call (fn, NULL_TREE);
return fn;
}
*************** convert_arg_to_ellipsis (tree arg)
*** 4379,4385 ****
if (!skip_evaluation)
warning ("cannot pass objects of non-POD type `%#T' through `...'; "
"call will abort at runtime", TREE_TYPE (arg));
! arg = call_builtin_trap (TREE_TYPE (arg));
}
return arg;
--- 4376,4384 ----
if (!skip_evaluation)
warning ("cannot pass objects of non-POD type `%#T' through `...'; "
"call will abort at runtime", TREE_TYPE (arg));
! arg = call_builtin_trap ();
! arg = build (COMPOUND_EXPR, integer_type_node, arg,
! integer_zero_node);
}
return arg;
*************** build_x_va_arg (tree expr, tree type)
*** 4404,4410 ****
warning ("cannot receive objects of non-POD type `%#T' through `...'; \
call will abort at runtime",
type);
! return call_builtin_trap (type);
}
return build_va_arg (expr, type);
--- 4403,4413 ----
warning ("cannot receive objects of non-POD type `%#T' through `...'; \
call will abort at runtime",
type);
! expr = convert (build_pointer_type (type), null_node);
! expr = build (COMPOUND_EXPR, TREE_TYPE (expr),
! call_builtin_trap (), expr);
! expr = build_indirect_ref (expr, NULL);
! return expr;
}
return build_va_arg (expr, type);