From e8d6ec55fd0e42332ef3014312c5b139c20d0fa8 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 11 Mar 2011 11:49:41 -0500 Subject: [PATCH] re PR c++/47808 ([C++0x] internal compiler error: in tsubst_copy_and_build, at cp/pt.c:13326) PR c++/47808 * decl.c (compute_array_index_type): Discard folding if it didn't produce a constant. From-SVN: r170878 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/decl.c | 2 ++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/g++.dg/cpp0x/regress/array1.C | 16 ++++++++++++++++ 4 files changed, 28 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/regress/array1.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index da75a77c3a9..29156efc4e3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2011-03-11 Jason Merrill + + PR c++/47808 + * decl.c (compute_array_index_type): Discard folding + if it didn't produce a constant. + 2011-03-11 Jakub Jelinek PR c++/48035 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 93c184845f9..f9d90ad3258 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7523,6 +7523,8 @@ compute_array_index_type (tree name, tree size, tsubst_flags_t complain) } size = maybe_constant_value (size); + if (!TREE_CONSTANT (size)) + size = osize; } if (error_operand_p (size)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5976bb4fd34..cf7d6d8a7cb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2011-03-11 Jason Merrill + + * g++.dg/cpp0x/regress/array1.C: New. + 2011-03-11 Richard Guenther PR tree-optimization/48067 diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/array1.C b/gcc/testsuite/g++.dg/cpp0x/regress/array1.C new file mode 100644 index 00000000000..629ab4103f5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/regress/array1.C @@ -0,0 +1,16 @@ +// PR c++/47808 +// { dg-options -std=c++0x } + +template +inline T abs (T const & x) { return x; } + +template +void f (T) +{ + typedef int ai[(abs(0.1) > 0) ? 1 : -1]; +} + +int main() +{ + f(1); +} -- 2.30.2