aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/constexpr.c
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/cp/constexpr.c
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/cp/constexpr.c')
-rw-r--r--gcc/cp/constexpr.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index bbb8ccf..fd80000 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -1846,7 +1846,12 @@ cxx_eval_array_reference (const constexpr_ctx *ctx, tree t,
if (!found)
{
- if (tree_int_cst_lt (index, array_type_nelts_top (TREE_TYPE (ary))))
+ tree nelts = array_type_nelts_top (TREE_TYPE (ary));
+ /* For VLAs, the number of elements won't be an integer constant. */
+ nelts = cxx_eval_constant_expression (ctx, nelts, false, non_constant_p,
+ overflow_p);
+ VERIFY_CONSTANT (nelts);
+ if (tree_int_cst_lt (index, nelts))
{
if (TREE_CODE (ary) == CONSTRUCTOR
&& CONSTRUCTOR_NO_IMPLICIT_ZERO (ary))