aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2018-12-14 20:36:33 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2018-12-14 20:36:33 +0100
commitfaa9232da39587b27b46341667d6d415d2af9280 (patch)
tree9bdd47d61567f7caaa33e66ef8756ceaf23ca65b /gcc
parent8d33eae8913eb827d595808416a3d27cffedbf56 (diff)
downloadgcc-faa9232da39587b27b46341667d6d415d2af9280.zip
gcc-faa9232da39587b27b46341667d6d415d2af9280.tar.gz
gcc-faa9232da39587b27b46341667d6d415d2af9280.tar.bz2
re PR c++/82294 (Array of objects with constexpr constructors initialized from space-inefficient memory image)
PR c++/82294 PR c++/87436 * init.c (build_vec_init): Change num_initialized_elts type from int to HOST_WIDE_INT. Build a RANGE_EXPR if e needs to be repeated more than once. From-SVN: r267142
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/init.c9
2 files changed, 14 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 46557be..6460a66 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,11 @@
+2018-12-14 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/82294
+ PR c++/87436
+ * init.c (build_vec_init): Change num_initialized_elts type from int
+ to HOST_WIDE_INT. Build a RANGE_EXPR if e needs to be repeated more
+ than once.
+
2018-12-13 Marek Polacek <polacek@redhat.com>
PR c++/88216 - ICE with class type in non-type template parameter.
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 5a31486..54a1dae 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -4104,7 +4104,7 @@ build_vec_init (tree base, tree maxindex, tree init,
tree compound_stmt;
int destroy_temps;
tree try_block = NULL_TREE;
- int num_initialized_elts = 0;
+ HOST_WIDE_INT num_initialized_elts = 0;
bool is_global;
tree obase = base;
bool xvalue = false;
@@ -4539,10 +4539,13 @@ build_vec_init (tree base, tree maxindex, tree init,
if (e)
{
- int max = tree_to_shwi (maxindex)+1;
- for (; num_initialized_elts < max; ++num_initialized_elts)
+ HOST_WIDE_INT last = tree_to_shwi (maxindex);
+ if (num_initialized_elts <= last)
{
tree field = size_int (num_initialized_elts);
+ if (num_initialized_elts != last)
+ field = build2 (RANGE_EXPR, sizetype, field,
+ size_int (last));
CONSTRUCTOR_APPEND_ELT (const_vec, field, e);
}
}