re PR c++/59097 (ICE with invalid statement expression as array size)
authorJason Merrill <jason@redhat.com>
Tue, 28 Jan 2014 04:30:16 +0000 (23:30 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 28 Jan 2014 04:30:16 +0000 (23:30 -0500)
PR c++/59097
* decl.c (compute_array_index_type): Don't call
maybe_constant_value for a non-integral expression.

From-SVN: r207161

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

index 635fb053e2c8aee46d4ea4cdbeee0b761a543f9c..3c58b6bb74a434289b8edda3f38d6dcfb63df8e7 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 38f2de0d06965cecdeac3341ad09ae05c6b0e8eb..7ebb05d451c38afe7e29d3bfbddc411293a10e5a 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" }
+}