aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2016-01-27 14:26:38 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2016-01-27 14:26:38 +0000
commit95e3030cfa307191f87da77bb98b101f2ed88bec (patch)
treebfe137203da0ccf55cba3f65e7c46f06a5d8bb62 /gcc/testsuite
parent5128d392c0c6509fac352b62cbb3cecf511e7b2a (diff)
downloadgcc-95e3030cfa307191f87da77bb98b101f2ed88bec.zip
gcc-95e3030cfa307191f87da77bb98b101f2ed88bec.tar.gz
gcc-95e3030cfa307191f87da77bb98b101f2ed88bec.tar.bz2
re PR c++/69496 ([C++ 14] ICE on VLA in constexpr function)
PR c++/69496 * constexpr.c (cxx_eval_array_reference): Evaluate the number of elements of the array. * g++.dg/ext/constexpr-vla1.C: New test. From-SVN: r232875
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/ext/constexpr-vla1.C30
2 files changed, 35 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8559a78..2ff4f7d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2016-01-27 Marek Polacek <polacek@redhat.com>
+
+ PR c++/69496
+ * g++.dg/ext/constexpr-vla1.C: New test.
+
2016-01-20 Christian Bruel <christian.bruel@st.com>
PR target/69245
diff --git a/gcc/testsuite/g++.dg/ext/constexpr-vla1.C b/gcc/testsuite/g++.dg/ext/constexpr-vla1.C
new file mode 100644
index 0000000..a5615bb
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/constexpr-vla1.C
@@ -0,0 +1,30 @@
+// PR c++/69496
+// { dg-do compile { target c++14 } }
+
+constexpr int
+fn_ok (int n)
+{
+ __extension__ int a[n] = { };
+ int z = 0;
+
+ for (unsigned i = 0; i < sizeof (a) / sizeof (int); ++i)
+ z += a[i];
+
+ return z;
+}
+
+
+constexpr int
+fn_not_ok (int n)
+{
+ __extension__ int a[n] = { };
+ int z = 0;
+
+ for (unsigned i = 0; i < sizeof (a); ++i)
+ z += a[i];
+
+ return z;
+}
+
+constexpr int n1 = fn_ok (3);
+constexpr int n2 = fn_not_ok (3); // { dg-error "array subscript out of bound" }