From 68a29e1cf46e63f8a50a8548287d93207bc04c34 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 20 Apr 2011 02:30:41 -0400 Subject: [PATCH] re PR c++/46304 (g++ crashes with ICE in bitmap_first_set_bit, at bitmap.c:770) PR c++/46304 * typeck.c (cp_build_binary_op): Fold COMPLEX_EXPR. From-SVN: r172754 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/typeck.c | 6 +++++- gcc/testsuite/ChangeLog | 2 ++ gcc/testsuite/g++.dg/ext/complex7.C | 6 ++++++ 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/ext/complex7.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7feb4279565..c7068ab97cc 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2011-04-19 Jason Merrill + 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. diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 89d3247db34..dcdc79084d0 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7e5d187a192..84c9d7c1bb1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,7 @@ 2011-04-19 Jason Merrill + * g++.dg/ext/complex7.C: New. + * g++.dg/ext/attrib41.C: New. 2011-04-19 Kaz Kojima diff --git a/gcc/testsuite/g++.dg/ext/complex7.C b/gcc/testsuite/g++.dg/ext/complex7.C new file mode 100644 index 00000000000..9d5463f94dc --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/complex7.C @@ -0,0 +1,6 @@ +// { dg-options "" } + +class A +{ + static const _Complex double x = 1.0 + 2.0i; +}; -- 2.30.2