aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2018-02-26 16:55:41 -0500
committerJason Merrill <jason@gcc.gnu.org>2018-02-26 16:55:41 -0500
commit8e9589bd6b308700c8601e802739b4d8f4d4cb83 (patch)
tree221d0a1df6f0596235c100891a574f8c302ef2a2
parentc2236b9b79e38e853026ac236984fcb5eabfb5df (diff)
downloadgcc-8e9589bd6b308700c8601e802739b4d8f4d4cb83.zip
gcc-8e9589bd6b308700c8601e802739b4d8f4d4cb83.tar.gz
gcc-8e9589bd6b308700c8601e802739b4d8f4d4cb83.tar.bz2
PR c++/84559 - ICE with constexpr VLA.
* constexpr.c (ensure_literal_type_for_constexpr_object): Check for constexpr variable with VLA type. From-SVN: r258015
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/constexpr.c7
-rw-r--r--gcc/testsuite/g++.dg/ext/constexpr-vla5.C7
3 files changed, 20 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 14f899c..3a2a17d 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2018-02-26 Jason Merrill <jason@redhat.com>
+
+ PR c++/84559 - ICE with constexpr VLA.
+ * constexpr.c (ensure_literal_type_for_constexpr_object): Check
+ for constexpr variable with VLA type.
+
2018-02-26 Jakub Jelinek <jakub@redhat.com>
PR c++/84558
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index b3de62a..4bbdbf4 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -112,6 +112,13 @@ ensure_literal_type_for_constexpr_object (tree decl)
cp_function_chain->invalid_constexpr = true;
}
}
+ else if (DECL_DECLARED_CONSTEXPR_P (decl)
+ && variably_modified_type_p (type, NULL_TREE))
+ {
+ error ("%<constexpr%> variable %qD has variably-modified type %qT",
+ decl, type);
+ decl = error_mark_node;
+ }
}
return decl;
}
diff --git a/gcc/testsuite/g++.dg/ext/constexpr-vla5.C b/gcc/testsuite/g++.dg/ext/constexpr-vla5.C
new file mode 100644
index 0000000..565d40a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/constexpr-vla5.C
@@ -0,0 +1,7 @@
+// PR c++/84559
+// { dg-do compile { target c++11 } }
+
+void foo(int i)
+{
+ constexpr char x[i] = ""; // { dg-error "" }
+}