Commit a10ce2f8 by Geoffrey Keating Committed by Geoffrey Keating

Index: cp/ChangeLog

2005-03-24  Geoffrey Keating  <geoffk@apple.com>

	* typeck.c (build_static_cast_1): Allow scalar_cast between
	any integral, floating, or enumeration type.

Index: testsuite/ChangeLog
2005-03-24  Geoffrey Keating  <geoffk@apple.com>

	* g++.dg/expr/cast3.C: New.

From-SVN: r97019
parent a9f15d83
2005-03-24 Geoffrey Keating <geoffk@apple.com>
* typeck.c (build_static_cast_1): Allow scalar_cast between
any integral, floating, or enumeration type.
2005-03-24 Steven Bosscher <stevenb@suse.de> 2005-03-24 Steven Bosscher <stevenb@suse.de>
* typeck.c (comptypes): First determine if the types are compatible * typeck.c (comptypes): First determine if the types are compatible
......
...@@ -4624,13 +4624,15 @@ build_static_cast_1 (tree type, tree expr, bool c_cast_p, ...@@ -4624,13 +4624,15 @@ build_static_cast_1 (tree type, tree expr, bool c_cast_p,
promotions, floating point promotion, integral conversions, promotions, floating point promotion, integral conversions,
floating point conversions, floating-integral conversions, floating point conversions, floating-integral conversions,
pointer conversions, and pointer to member conversions. */ pointer conversions, and pointer to member conversions. */
if ((ARITHMETIC_TYPE_P (type) && ARITHMETIC_TYPE_P (intype)) /* DR 128
/* DR 128
A value of integral _or enumeration_ type can be explicitly
A value of integral _or enumeration_ type can be explicitly converted to an enumeration type. */
converted to an enumeration type. */ /* The effect of all that is that any conversion between any two
|| (INTEGRAL_OR_ENUMERATION_TYPE_P (type) types which are integral, floating, or enumeration types can be
&& INTEGRAL_OR_ENUMERATION_TYPE_P (intype))) performed. */
if ((INTEGRAL_TYPE_P (type) || SCALAR_FLOAT_TYPE_P (type))
&& (INTEGRAL_TYPE_P (intype) || SCALAR_FLOAT_TYPE_P (intype)))
{ {
expr = ocp_convert (type, expr, CONV_C_CAST, LOOKUP_NORMAL); expr = ocp_convert (type, expr, CONV_C_CAST, LOOKUP_NORMAL);
......
2005-03-24 Geoffrey Keating <geoffk@apple.com>
* g++.dg/expr/cast3.C: New.
2005-03-24 David Edelsohn <edelsohn@gnu.org> 2005-03-24 David Edelsohn <edelsohn@gnu.org>
* gcc.c-torture/execute/20020720-1.x: XFAIL for all powerpc and * gcc.c-torture/execute/20020720-1.x: XFAIL for all powerpc and
......
// { dg-do compile }
enum MyState
{
QUIT = 0,
START,
STOP,
PAUSE
};
double GetDouble()
{
return 1.0;
}
int main()
{
MyState the_state;
the_state = (MyState)GetDouble(); // { dg-bogus "invalid cast" }
return 0;
}
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