re PR c++/46304 (g++ crashes with ICE in bitmap_first_set_bit, at bitmap.c:770)
authorJason Merrill <jason@redhat.com>
Wed, 20 Apr 2011 06:30:41 +0000 (02:30 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 20 Apr 2011 06:30:41 +0000 (02:30 -0400)
PR c++/46304
* typeck.c (cp_build_binary_op): Fold COMPLEX_EXPR.

From-SVN: r172754

gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/complex7.C [new file with mode: 0644]

index 7feb42795654f124ab664030bf20d763542e5cc9..c7068ab97cc6a269bc89ce9477b5ccbeda8ba235 100644 (file)
@@ -1,5 +1,8 @@
 2011-04-19  Jason Merrill  <jason@redhat.com>
 
+       PR c++/46304
+       * typeck.c (cp_build_binary_op): Fold COMPLEX_EXPR.
+
        PR c++/45267
        * decl.c (duplicate_decls): Keep always_inline attribute
        in sync with DECL_DISREGARD_INLINE_LIMITS.
index 89d3247db3417cb61ba2716dda13bf5d36a7c106..dcdc79084d07160514cddd8f4e54ac20487e5acb 100644 (file)
@@ -4357,7 +4357,11 @@ cp_build_binary_op (location_t location,
                  gcc_unreachable();
                }
            }
-         return build2 (COMPLEX_EXPR, result_type, real, imag);
+         real = fold_if_not_in_template (real);
+         imag = fold_if_not_in_template (imag);
+         result = build2 (COMPLEX_EXPR, result_type, real, imag);
+         result = fold_if_not_in_template (result);
+         return result;
        }
 
       /* For certain operations (which identify themselves by shorten != 0)
index 7e5d187a19299b3420245d22868af979cb25d9e3..84c9d7c1bb11b62a1873506d931dd81db46bbb96 100644 (file)
@@ -1,5 +1,7 @@
 2011-04-19  Jason Merrill  <jason@redhat.com>
 
+       * g++.dg/ext/complex7.C: New.
+
        * g++.dg/ext/attrib41.C: New.
 
 2011-04-19  Kaz Kojima  <kkojima@gcc.gnu.org>
diff --git a/gcc/testsuite/g++.dg/ext/complex7.C b/gcc/testsuite/g++.dg/ext/complex7.C
new file mode 100644 (file)
index 0000000..9d5463f
--- /dev/null
@@ -0,0 +1,6 @@
+// { dg-options "" }
+
+class A
+{
+  static const _Complex double x = 1.0 + 2.0i;
+};