From 5a20ffcb3afa4c44d0518d30010f002a32a8f7b2 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Mon, 11 Jun 2012 13:58:29 +0000 Subject: [PATCH] re PR c++/53605 (Compiler ICEs in size_binop_loc) 2012-06-11 Richard Guenther PR c++/53616 * mangle.c (write_array_type): Use double-ints for array domain arithmetic. * g++.dg/ext/pr53605.C: New testcase. From-SVN: r188386 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/mangle.c | 6 ++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/ext/pr53605.C | 16 ++++++++++++++++ 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ext/pr53605.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 832ba9eac43..0b1602a7892 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2012-06-11 Richard Guenther + + PR c++/53616 + * mangle.c (write_array_type): Use double-ints for array domain + arithmetic. + 2012-06-07 Fabien Chêne PR c++/51214 diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index c8018483b81..2ec626c9d5d 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -3119,8 +3119,10 @@ write_array_type (const tree type) { /* The ABI specifies that we should mangle the number of elements in the array, not the largest allowed index. */ - max = size_binop (PLUS_EXPR, max, size_one_node); - write_unsigned_number (tree_low_cst (max, 1)); + double_int dmax + = double_int_add (tree_to_double_int (max), double_int_one); + gcc_assert (double_int_fits_in_uhwi_p (dmax)); + write_unsigned_number (dmax.low); } else { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bab23788070..baa04c04ad2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-06-11 Richard Guenther + + PR c++/53616 + * g++.dg/ext/pr53605.C: New testcase. + 2012-06-11 Eric Botcazou * gnat.dg/specs/array1.ads: New test. diff --git a/gcc/testsuite/g++.dg/ext/pr53605.C b/gcc/testsuite/g++.dg/ext/pr53605.C new file mode 100644 index 00000000000..0b902dd844e --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/pr53605.C @@ -0,0 +1,16 @@ +// { dg-do compile } + +// Avoid -pedantic-error default +// { dg-options "" } + +template +class EqHelper { +public: + template + static int Compare( const T1& expected, + const T2& actual); +}; +void foo(){ + static const int kData[] = {}; + ::EqHelper::Compare(kData, "abc"); +}