re PR c++/38577 (ICE: tree check: expected call_expr, have compound_expr in build_new_method_call, at cp/call.c:6000)

PR c++/38577
	* call.c (build_new_method_call): Handle call being COMPOUND_EXPR
	or NOP_EXPR.

	* g++.dg/template/call6.C: New test.

From-SVN: r142842
This commit is contained in:
Jakub Jelinek 2008-12-19 20:33:28 +01:00 committed by Jakub Jelinek
parent 735baa21c2
commit 6cea69fe29
4 changed files with 46 additions and 0 deletions

View file

@ -1,3 +1,9 @@
2008-12-19 Jakub Jelinek <jakub@redhat.com>
PR c++/38577
* call.c (build_new_method_call): Handle call being COMPOUND_EXPR
or NOP_EXPR.
2008-12-18 Jakub Jelinek <jakub@redhat.com>
PR c++/38427

View file

@ -5993,6 +5993,15 @@ build_new_method_call (tree instance, tree fns, tree args,
if (processing_template_decl && call != error_mark_node)
{
bool cast_to_void = false;
if (TREE_CODE (call) == COMPOUND_EXPR)
call = TREE_OPERAND (call, 1);
else if (TREE_CODE (call) == NOP_EXPR)
{
cast_to_void = true;
call = TREE_OPERAND (call, 0);
}
if (TREE_CODE (call) == INDIRECT_REF)
call = TREE_OPERAND (call, 0);
call = (build_min_non_dep_call_list
@ -6001,6 +6010,8 @@ build_new_method_call (tree instance, tree fns, tree args,
orig_instance, orig_fns, NULL_TREE),
orig_args));
call = convert_from_reference (call);
if (cast_to_void)
call = build_nop (void_type_node, call);
}
/* Free all the conversions we allocated. */

View file

@ -1,3 +1,8 @@
2008-12-19 Jakub Jelinek <jakub@redhat.com>
PR c++/38577
* g++.dg/template/call6.C: New test.
2008-12-19 Janis Johnson <janis187@us.ibm.com>
Revert:

View file

@ -0,0 +1,24 @@
// PR c++/38577
// { dg-do compile }
struct A
{
static A *bar ();
};
struct B : public A
{
static void baz ();
};
template <class T>
void foo ()
{
(static_cast<B *> (A::bar ()))->baz ();
}
void
bar ()
{
foo<int> ();
}