Commit d149fba0 by Volker Reichelt Committed by Volker Reichelt

re PR c++/10385 (Internal compiler error in build_up_reference, at cp/cvt.c:353,…

re PR c++/10385 (Internal compiler error in build_up_reference, at cp/cvt.c:353, on invalid dynamic_cast)

	PR c++/10385
	* rtti.c (build_dynamic_cast_1): Check for invalid conversions
	before calling convert_to_reference.
	* cvt.c (convert_to_reference): Assert that reftype is a
	REFERENCE_TYPE.

	* g++.dg/conversion/dynamic1.C: New test.

From-SVN: r113084
parent 37e7dc12
2006-04-19 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/10385
* rtti.c (build_dynamic_cast_1): Check for invalid conversions
before calling convert_to_reference.
* cvt.c (convert_to_reference): Assert that reftype is a
REFERENCE_TYPE.
2006-04-19 Mark Mitchell <mark@codesourcery.com>
PR c++/27102
......
......@@ -460,6 +460,7 @@ convert_to_reference (tree reftype, tree expr, int convtype,
intype = TREE_TYPE (expr);
gcc_assert (TREE_CODE (intype) != REFERENCE_TYPE);
gcc_assert (TREE_CODE (reftype) == REFERENCE_TYPE);
intype = TYPE_MAIN_VARIANT (intype);
......
......@@ -513,10 +513,7 @@ build_dynamic_cast_1 (tree type, tree expr)
}
else
{
/* Apply trivial conversion T -> T& for dereferenced ptrs. */
exprtype = build_reference_type (exprtype);
expr = convert_to_reference (exprtype, expr, CONV_IMPLICIT,
LOOKUP_NORMAL, NULL_TREE);
/* T is a reference type, v shall be an lvalue of a complete class
type, and the result is an lvalue of the type referred to by T. */
......@@ -532,6 +529,9 @@ build_dynamic_cast_1 (tree type, tree expr)
goto fail;
}
/* Apply trivial conversion T -> T& for dereferenced ptrs. */
expr = convert_to_reference (exprtype, expr, CONV_IMPLICIT,
LOOKUP_NORMAL, NULL_TREE);
}
/* The dynamic_cast operator shall not cast away constness. */
......
2006-04-19 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/10385
* g++.dg/conversion/dynamic1.C: New test.
2006-04-19 Mark Mitchell <mark@codesourcery.com>
PR c++/27102
// PR c++/10385
// Origin: <douglas@coc.ufrj.br>
// { dg-do compile }
struct A
{
void foo();
};
A& bar();
void baz()
{
dynamic_cast<A&>( bar().foo ); // { dg-error "cannot dynamic_cast" }
}
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