From a04678ca5666102eca111375a79c7e209663b2f1 Mon Sep 17 00:00:00 2001 From: Gabriel Dos Reis Date: Tue, 25 Apr 2000 00:11:34 +0000 Subject: [PATCH] call.c (standard_conversion): Accept conversion between COMPLEX_TYPEs 2000-04-24 Gabriel Dos Reis * call.c (standard_conversion): Accept conversion between COMPLEX_TYPEs * cvt.c (ocp_convert): Handle conversion to COMPLEX_TYPE From-SVN: r33396 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/call.c | 20 ++++++++++++++++++++ gcc/cp/cvt.c | 4 ++++ 3 files changed, 31 insertions(+) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index fbd1d33f31d..295be198d2c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2000-04-24 Gabriel Dos Reis + + * call.c (standard_conversion): Accept conversion between + COMPLEX_TYPEs + + * cvt.c (ocp_convert): Handle conversion to COMPLEX_TYPE + 2000-04-24 Zack Weinberg * decl2.c (finish_file): Remove double setup for accounting diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 085e264e485..d8dda3e2416 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -679,6 +679,26 @@ standard_conversion (to, from, expr) else if (fromref || (expr && real_lvalue_p (expr))) conv = build_conv (RVALUE_CONV, from, conv); + /* Allow conversion between `__complex__' data types */ + if (tcode == COMPLEX_TYPE && fcode == COMPLEX_TYPE) + { + /* The standard conversion sequence to convert FROM to TO is + the standard conversion sequence to perform componentwise + conversion. */ + tree part_conv = standard_conversion + (TREE_TYPE (to), TREE_TYPE (from), NULL_TREE); + + if (part_conv) + { + conv = build_conv (TREE_CODE (part_conv), to, conv); + ICS_STD_RANK (conv) = ICS_STD_RANK (part_conv); + } + else + conv = NULL_TREE; + + return conv; + } + if (same_type_p (from, to)) return conv; diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 8f501c0f9b1..376cdaa3460 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -692,6 +692,10 @@ ocp_convert (type, expr, convtype, flags) that can result in infinite recursion; fold will call convert, which will call ocp_convert, etc. */ return e; + /* For complex data types, we need to perform componentwise + conversion. */ + else if (TREE_CODE (type) == COMPLEX_TYPE) + return fold (convert_to_complex (type, e)); else return fold (build1 (NOP_EXPR, type, e)); } -- 2.30.2