aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/typeck2.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2017-04-03 17:15:36 -0400
committerJason Merrill <jason@gcc.gnu.org>2017-04-03 17:15:36 -0400
commit5a68fae797b88216b40eb6af8c75dec6e98b983c (patch)
tree28f3a1d200fa86ca4057f09c132ba79749c015a7 /gcc/cp/typeck2.c
parentb0dfb235e837330a5f91ff14092aa76684fee24d (diff)
downloadgcc-5a68fae797b88216b40eb6af8c75dec6e98b983c.zip
gcc-5a68fae797b88216b40eb6af8c75dec6e98b983c.tar.gz
gcc-5a68fae797b88216b40eb6af8c75dec6e98b983c.tar.bz2
PR sanitizer/79993 - ICE with VLA initialization from string
PR c++/69487 - wrong VLA initialization from string * init.c (finish_length_check): Split out from build_vec_init. (build_vec_init): Handle STRING_CST. * typeck2.c (split_nonconstant_init): Handle STRING_CST. (digest_init_r): Don't give a STRING_CST VLA type. From-SVN: r246662
Diffstat (limited to 'gcc/cp/typeck2.c')
-rw-r--r--gcc/cp/typeck2.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 58a01c9..d1a3930 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -749,6 +749,10 @@ split_nonconstant_init (tree dest, tree init)
DECL_INITIAL (dest) = init;
TREE_READONLY (dest) = 0;
}
+ else if (TREE_CODE (init) == STRING_CST
+ && array_of_runtime_bound_p (TREE_TYPE (dest)))
+ code = build_vec_init (dest, NULL_TREE, init, /*value-init*/false,
+ /*from array*/1, tf_warning_or_error);
else
code = build2 (INIT_EXPR, TREE_TYPE (dest), dest, init);
@@ -1066,7 +1070,8 @@ digest_init_r (tree type, tree init, bool nested, int flags,
}
}
- if (type != TREE_TYPE (init))
+ if (type != TREE_TYPE (init)
+ && !variably_modified_type_p (type, NULL_TREE))
{
init = copy_node (init);
TREE_TYPE (init) = type;