call.c (standard_conversion): Accept conversion between COMPLEX_TYPEs
authorGabriel Dos Reis <gdr@codesourcery.com>
Tue, 25 Apr 2000 00:11:34 +0000 (00:11 +0000)
committerGabriel Dos Reis <gdr@gcc.gnu.org>
Tue, 25 Apr 2000 00:11:34 +0000 (00:11 +0000)
2000-04-24  Gabriel Dos Reis  <gdr@codesourcery.com>

        * call.c (standard_conversion): Accept conversion between
        COMPLEX_TYPEs

        * cvt.c (ocp_convert): Handle conversion to COMPLEX_TYPE

From-SVN: r33396

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/cvt.c

index fbd1d33..295be19 100644 (file)
@@ -1,3 +1,10 @@
+2000-04-24  Gabriel Dos Reis  <gdr@codesourcery.com>
+
+       * call.c (standard_conversion): Accept conversion between
+       COMPLEX_TYPEs 
+
+       * cvt.c (ocp_convert): Handle conversion to COMPLEX_TYPE
+
 2000-04-24  Zack Weinberg  <zack@wolery.cumb.org>
 
        * decl2.c (finish_file): Remove double setup for accounting
index 085e264..d8dda3e 100644 (file)
@@ -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;
 
index 8f501c0..376cdaa 100644 (file)
@@ -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));
     }