re PR c++/47808 ([C++0x] internal compiler error: in tsubst_copy_and_build, at cp...
authorJason Merrill <jason@redhat.com>
Fri, 11 Mar 2011 16:49:41 +0000 (11:49 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 11 Mar 2011 16:49:41 +0000 (11:49 -0500)
PR c++/47808
* decl.c (compute_array_index_type): Discard folding
if it didn't produce a constant.

From-SVN: r170878

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/regress/array1.C [new file with mode: 0644]

index da75a77c3a98013f27673ce0f3f26717cfae6e53..29156efc4e3c5ef5f1413a3d7cbda77de1f7a44b 100644 (file)
@@ -1,3 +1,9 @@
+2011-03-11  Jason Merrill  <jason@redhat.com>
+
+       PR c++/47808
+       * decl.c (compute_array_index_type): Discard folding
+       if it didn't produce a constant.
+
 2011-03-11  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/48035
index 93c184845f9131b49fd2abf552e529a006ccf43b..f9d90ad32581354923a7ed836bfc1ae5f63fb277 100644 (file)
@@ -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))
index 5976bb4fd3405b2cefced65367bc1918429f3764..cf7d6d8a7cb906374bc25e3910f5b5cf3bb0daad 100644 (file)
@@ -1,3 +1,7 @@
+2011-03-11  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/cpp0x/regress/array1.C: New.
+
 2011-03-11  Richard Guenther  <rguenther@suse.de>
 
        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 (file)
index 0000000..629ab41
--- /dev/null
@@ -0,0 +1,16 @@
+// PR c++/47808
+// { dg-options -std=c++0x }
+
+template <typename T>
+inline T abs (T const & x) { return x; }
+
+template <typename T>
+void f (T)
+{
+  typedef int ai[(abs(0.1) > 0) ? 1 : -1];
+}
+
+int main()
+{
+  f(1);
+}