aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/constexpr.c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2019-01-31 20:21:11 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2019-01-31 20:21:11 +0000
commitb27f74e77740a0982621af083a5743383a4de9d3 (patch)
tree61a150f1a13f1a04a1e07e7f0a4d5b6806b740c8 /gcc/cp/constexpr.c
parent1d4b4f4979171ef0dacc452439e3a317795441db (diff)
downloadgcc-b27f74e77740a0982621af083a5743383a4de9d3.zip
gcc-b27f74e77740a0982621af083a5743383a4de9d3.tar.gz
gcc-b27f74e77740a0982621af083a5743383a4de9d3.tar.bz2
PR c++/89083, c++/80864 - ICE with list initialization in template.
* constexpr.c (adjust_temp_type): Use copy_node and change the type instead of using build_constructor. * decl.c (reshape_init_r): Don't reshape a digested initializer. Return the initializer for COMPOUND_LITERAL_P. * g++.dg/cpp0x/initlist107.C: New test. * g++.dg/cpp0x/initlist108.C: New test. * g++.dg/cpp0x/initlist109.C: New test. * g++.dg/cpp0x/initlist110.C: New test. * g++.dg/cpp0x/initlist111.C: New test. * g++.dg/cpp0x/initlist112.C: New test. * g++.dg/init/ptrfn4.C: New test. From-SVN: r268428
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 4268141..19eb44f 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -1291,7 +1291,12 @@ adjust_temp_type (tree type, tree temp)
return temp;
/* Avoid wrapping an aggregate value in a NOP_EXPR. */
if (TREE_CODE (temp) == CONSTRUCTOR)
- return build_constructor (type, CONSTRUCTOR_ELTS (temp));
+ {
+ /* build_constructor wouldn't retain various CONSTRUCTOR flags. */
+ tree t = copy_node (temp);
+ TREE_TYPE (t) = type;
+ return t;
+ }
if (TREE_CODE (temp) == EMPTY_CLASS_EXPR)
return build0 (EMPTY_CLASS_EXPR, type);
gcc_assert (scalarish_type_p (type));