OSDN Git Service

PR c++/47808
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 11 Mar 2011 16:49:41 +0000 (16:49 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 11 Mar 2011 16:49:41 +0000 (16:49 +0000)
* decl.c (compute_array_index_type): Discard folding
if it didn't produce a constant.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@170878 138bc75d-0d04-0410-961f-82ee72b054a4

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

index da75a77..29156ef 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 93c1848..f9d90ad 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 5976bb4..cf7d6d8 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);
+}