summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2018-02-26 21:55:41 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2018-02-26 21:55:41 +0000
commitfdafeeb77fda0afb9260ed55afcffeafcb35b8b8 (patch)
tree221d0a1df6f0596235c100891a574f8c302ef2a2
parenteb7c25ccad56e9f580f2362114cb3f952af8c9e2 (diff)
downloadgcc-fdafeeb77fda0afb9260ed55afcffeafcb35b8b8.tar.gz
PR c++/84559 - ICE with constexpr VLA.
* constexpr.c (ensure_literal_type_for_constexpr_object): Check for constexpr variable with VLA type. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@258015 138bc75d-0d04-0410-961f-82ee72b054a4
-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 14f899c1881..3a2a17d5720 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 b3de62a5bea..4bbdbf43487 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 00000000000..565d40ab077
--- /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 "" }
+}