re PR target/31388 (ICE building libiberty multilib for mips16 multilibs)
authorMark Mitchell <mark@codesourcery.com>
Thu, 26 Apr 2007 02:29:43 +0000 (02:29 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Thu, 26 Apr 2007 02:29:43 +0000 (02:29 +0000)
PR c++/31388
* cp-tree.h (ARITHMETIC_TYPE): Include COMPLEX_TYPE.
* typeck.c (type_after_usual_arithmetic_conversions): Adjust, as
COMPLEX_TYPE is now an ARITHMETIC_TYPE.
* init.c (build_zero_init): Adjust, as
COMPLEX_TYPE is now a SCALAR_TYPE.
* typeck2.c (digest_init): Allow brace-enclosed initializers for
COMPLEX_TYPE, even though that is now a SCALAR_TYPE.

PR c++/31388
* g++.dg/ext/complex2.C: New test.

From-SVN: r124172

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/init.c
gcc/cp/typeck.c
gcc/cp/typeck2.c
gcc/testsuite/g++.dg/ext/complex2.C [new file with mode: 0644]

index 37b7742734e7f8ffefa445f9baa24118989cebad..3846c0bb6a10e3b3ba1d6edfa7169be50d0a9038 100644 (file)
@@ -1,3 +1,14 @@
+2007-04-24  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/31388
+       * cp-tree.h (ARITHMETIC_TYPE): Include COMPLEX_TYPE.
+       * typeck.c (type_after_usual_arithmetic_conversions): Adjust, as
+       COMPLEX_TYPE is now an ARITHMETIC_TYPE.
+       * init.c (build_zero_init): Adjust, as
+       COMPLEX_TYPE is now a SCALAR_TYPE.
+       * typeck2.c (digest_init): Allow brace-enclosed initializers for
+       COMPLEX_TYPE, even though that is now a SCALAR_TYPE.
+
 2007-04-25  Paolo Carlini  <pcarlini@suse.de>
 
        * semantics.c (classtype_has_nothrow_copy_or_assign_p): Adjust
index 27f5b8caf895ec860b0343db49fff50102f90f9a..fb682c7ee04cbc988bf59c29a061d749b8520747 100644 (file)
@@ -2660,14 +2660,21 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
 /* [basic.fundamental]
 
    Integral and floating types are collectively called arithmetic
-   types.  Keep these checks in ascending code order.  */
+   types.  
+
+   As a GNU extension, we also accept complex types.
+
+   Keep these checks in ascending code order.  */
 #define ARITHMETIC_TYPE_P(TYPE) \
-  (CP_INTEGRAL_TYPE_P (TYPE) || TREE_CODE (TYPE) == REAL_TYPE)
+  (CP_INTEGRAL_TYPE_P (TYPE) \
+   || TREE_CODE (TYPE) == REAL_TYPE \
+   || TREE_CODE (TYPE) == COMPLEX_TYPE)
 
 /* [basic.types]
 
    Arithmetic types, enumeration types, pointer types, and
    pointer-to-member types, are collectively called scalar types.
+   
    Keep these checks in ascending code order.  */
 #define SCALAR_TYPE_P(TYPE)                    \
   (TYPE_PTRMEM_P (TYPE)                                \
index 679be2067e67108e60a22b49139a0e60e354c123..3023cf09d4bdd190c786f33893405b23ff2888dc 100644 (file)
@@ -178,8 +178,7 @@ build_zero_init (tree type, tree nelts, bool static_storage_p)
        items with static storage duration that are not otherwise
        initialized are initialized to zero.  */
     ;
-  else if (SCALAR_TYPE_P (type)
-          || TREE_CODE (type) == COMPLEX_TYPE)
+  else if (SCALAR_TYPE_P (type))
     init = convert (type, integer_zero_node);
   else if (CLASS_TYPE_P (type))
     {
index f3358c79c6c1d8302bf2ad05211f3438a9acdc9a..7e816f102f780bf18b73abf7fd94ef662a458a66 100644 (file)
@@ -258,11 +258,9 @@ type_after_usual_arithmetic_conversions (tree t1, tree t2)
 
   /* FIXME: Attributes.  */
   gcc_assert (ARITHMETIC_TYPE_P (t1)
-             || TREE_CODE (t1) == COMPLEX_TYPE
              || TREE_CODE (t1) == VECTOR_TYPE
              || TREE_CODE (t1) == ENUMERAL_TYPE);
   gcc_assert (ARITHMETIC_TYPE_P (t2)
-             || TREE_CODE (t2) == COMPLEX_TYPE
              || TREE_CODE (t2) == VECTOR_TYPE
              || TREE_CODE (t2) == ENUMERAL_TYPE);
 
@@ -757,9 +755,9 @@ common_type (tree t1, tree t2)
   code2 = TREE_CODE (t2);
 
   if ((ARITHMETIC_TYPE_P (t1) || code1 == ENUMERAL_TYPE
-       || code1 == COMPLEX_TYPE || code1 == VECTOR_TYPE)
+       || code1 == VECTOR_TYPE)
       && (ARITHMETIC_TYPE_P (t2) || code2 == ENUMERAL_TYPE
-         || code2 == COMPLEX_TYPE || code2 == VECTOR_TYPE))
+         || code2 == VECTOR_TYPE))
     return type_after_usual_arithmetic_conversions (t1, t2);
 
   else if ((TYPE_PTR_P (t1) && TYPE_PTR_P (t2))
index 5f6cf0d35a5b994dff8fa5cb20cedadc6e7949e6..9ded7bbf8644406c379639245f97c9e14a14ba23 100644 (file)
@@ -702,7 +702,8 @@ digest_init (tree type, tree init)
     }
 
   /* Handle scalar types (including conversions) and references.  */
-  if (SCALAR_TYPE_P (type) || code == REFERENCE_TYPE)
+  if (TREE_CODE (type) != COMPLEX_TYPE
+      && (SCALAR_TYPE_P (type) || code == REFERENCE_TYPE))
     return convert_for_initialization (0, type, init, LOOKUP_NORMAL,
                                       "initialization", NULL_TREE, 0);
 
diff --git a/gcc/testsuite/g++.dg/ext/complex2.C b/gcc/testsuite/g++.dg/ext/complex2.C
new file mode 100644 (file)
index 0000000..c9e8cdc
--- /dev/null
@@ -0,0 +1,5 @@
+// PR c++/31388
+// { dg-options "" }
+
+bool b = !0i;
+