Commit 3a73bcc6 by Mark Mitchell Committed by Mark Mitchell

re PR c++/11332 (Spurious error with casts in ?: expression)

	PR c++/11332
	* typeck.c (build_static_cast): Avoid returning expressions with
	reference type.

	PR c++/11332
	* g++.dg/expr/static_cast2.C: New test.

From-SVN: r68580
parent 560d4c59
2003-06-26 Mark Mitchell <mark@codesourcery.com>
PR c++/11332
* typeck.c (build_static_cast): Avoid returning expressions with
reference type.
2003-06-26 Nathan Sidwell <nathan@codesourcery.com> 2003-06-26 Nathan Sidwell <nathan@codesourcery.com>
* call.c (build_op_delete_call): Use strip_array_call. Correct * call.c (build_op_delete_call): Use strip_array_call. Correct
......
...@@ -4814,7 +4814,7 @@ build_static_cast (tree type, tree expr) ...@@ -4814,7 +4814,7 @@ build_static_cast (tree type, tree expr)
t. */ t. */
result = perform_direct_initialization_if_possible (type, expr); result = perform_direct_initialization_if_possible (type, expr);
if (result) if (result)
return result; return convert_from_reference (result);
/* [expr.static.cast] /* [expr.static.cast]
...@@ -4848,8 +4848,9 @@ build_static_cast (tree type, tree expr) ...@@ -4848,8 +4848,9 @@ build_static_cast (tree type, tree expr)
/* Convert from B* to D*. */ /* Convert from B* to D*. */
expr = build_base_path (MINUS_EXPR, build_address (expr), expr = build_base_path (MINUS_EXPR, build_address (expr),
base, /*nonnull=*/false); base, /*nonnull=*/false);
/* Convert the pointer to a reference. */ /* Convert the pointer to a reference -- but then remember that
return build_nop (type, expr); there are no expressions with reference type in C++. */
return convert_from_reference (build_nop (type, expr));
} }
/* [expr.static.cast] /* [expr.static.cast]
......
2003-06-26 Mark Mitchell <mark@codesourcery.com>
PR c++/11332
* g++.dg/expr/static_cast2.C: New test.
2003-06-26 Roger Sayle <roger@eyesopen.com> 2003-06-26 Roger Sayle <roger@eyesopen.com>
Jakub Jelinek <jakub@redhat.com> Jakub Jelinek <jakub@redhat.com>
......
struct B {};
int main () {
B a;
(1 ? static_cast<B&>(a) :
*static_cast<B*>(&a));
}
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