PR c++/59097
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 28 Jan 2014 04:30:16 +0000 (04:30 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 28 Jan 2014 04:30:16 +0000 (04:30 +0000)
* decl.c (compute_array_index_type): Don't call
maybe_constant_value for a non-integral expression.

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

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

index 635fb05..3c58b6b 100644 (file)
@@ -1,3 +1,9 @@
+2014-01-27  Jason Merrill  <jason@redhat.com>
+
+       PR c++/59097
+       * decl.c (compute_array_index_type): Don't call
+       maybe_constant_value for a non-integral expression.
+
 2014-01-24  Balaji V. Iyer  <balaji.v.iyer@intel.com>
 
        * call.c (magic_varargs_p): Replaced flag_enable_cilkplus with
index 38f2de0..7ebb05d 100644 (file)
@@ -8262,7 +8262,9 @@ compute_array_index_type (tree name, tree size, tsubst_flags_t complain)
              abi_1_itype = error_mark_node;
            }
 
-         size = maybe_constant_value (size);
+         if (INTEGRAL_OR_UNSCOPED_ENUMERATION_TYPE_P (type))
+           size = maybe_constant_value (size);
+
          if (!TREE_CONSTANT (size))
            size = osize;
        }
diff --git a/gcc/testsuite/g++.dg/ext/stmtexpr15.C b/gcc/testsuite/g++.dg/ext/stmtexpr15.C
new file mode 100644 (file)
index 0000000..83a831c
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/59097
+// { dg-options "" }
+
+void foo()
+{
+  int x[({ return; })];                // { dg-error "non-integral" }
+}