Commit a90f9bb1 by Jason Merrill Committed by Jason Merrill

re PR c++/15142 (Internal compiler error when passing a string where a char* is…

re PR c++/15142 (Internal compiler error when passing a string where a char* is expecteted in a throw statement)

        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.

From-SVN: r82556
parent 95c73b23
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.
2004-06-01 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
PR c++/13092
......
......@@ -182,7 +182,7 @@ static conversion *direct_reference_binding (tree, conversion *);
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 call_builtin_trap (void);
static tree prep_operand (tree);
static void add_candidates (tree, tree, tree, bool, tree, tree,
int, struct z_candidate **);
......@@ -4325,18 +4325,15 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
LOOKUP_NORMAL|LOOKUP_NO_CONVERSION);
}
/* Build a call to __builtin_trap which can be used as an expression of
type TYPE. */
/* Build a call to __builtin_trap. */
static tree
call_builtin_trap (tree type)
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);
fn = build (COMPOUND_EXPR, type, fn, error_mark_node);
fn = force_target_expr (type, fn);
return fn;
}
......@@ -4379,7 +4376,9 @@ convert_arg_to_ellipsis (tree arg)
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));
arg = call_builtin_trap ();
arg = build (COMPOUND_EXPR, integer_type_node, arg,
integer_zero_node);
}
return arg;
......@@ -4404,7 +4403,11 @@ build_x_va_arg (tree expr, tree type)
warning ("cannot receive objects of non-POD type `%#T' through `...'; \
call will abort at runtime",
type);
return call_builtin_trap (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);
......
// PR c++/15142
// Bug: We were aborting after giving a warning about passing a non-POD.
// Suppress the warning about undefined behavior.
// { dg-options "-w" }
struct B {
B() throw() { }
B(const B&) throw() { }
};
struct X {
B a;
X& operator=(const X&);
};
struct S { S(...); };
void SillyFunc() {
throw S(X());
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment