diff options
author | Jason Merrill <jason@redhat.com> | 2015-06-17 16:45:32 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2015-06-17 16:45:32 -0400 |
commit | 9fa6ffe1bacd71b13d7b00e6636e9f2afbe01d2e (patch) | |
tree | 73bfc860816ba6284774ad8351006b5692078102 /gcc/cp | |
parent | cc7f3d0eeef05fb8fc11384a9a29afae10a54cc7 (diff) | |
download | gcc-9fa6ffe1bacd71b13d7b00e6636e9f2afbe01d2e.zip gcc-9fa6ffe1bacd71b13d7b00e6636e9f2afbe01d2e.tar.gz gcc-9fa6ffe1bacd71b13d7b00e6636e9f2afbe01d2e.tar.bz2 |
re PR c++/66515 (g++ segfaults when creating an std::initializer_list)
PR c++/66515
* call.c (implicit_conversion): Call reshape_init here, early.
(build_aggr_conv): Not here.
From-SVN: r224581
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/call.c | 15 |
2 files changed, 18 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 010442f..0ebce19 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-06-17 Jason Merrill <jason@redhat.com> + + PR c++/66515 + * call.c (implicit_conversion): Call reshape_init here, early. + (build_aggr_conv): Not here. + 2015-06-17 Jakub Jelinek <jakub@redhat.com> PR c++/66571 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index d4da80a..5d1891d 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -868,9 +868,7 @@ build_aggr_conv (tree type, tree ctor, int flags, tsubst_flags_t complain) tree field = next_initializable_field (TYPE_FIELDS (type)); tree empty_ctor = NULL_TREE; - ctor = reshape_init (type, ctor, tf_none); - if (ctor == error_mark_node) - return NULL; + /* We already called reshape_init in implicit_conversion. */ /* The conversions within the init-list aren't affected by the enclosing context; they're always simple copy-initialization. */ @@ -1759,6 +1757,17 @@ implicit_conversion (tree to, tree from, tree expr, bool c_cast_p, to that conversion. */ complain &= ~tf_error; + /* Call reshape_init early to remove redundant braces. */ + if (expr && BRACE_ENCLOSED_INITIALIZER_P (expr) + && COMPLETE_TYPE_P (complete_type (to)) + && CP_AGGREGATE_TYPE_P (to)) + { + expr = reshape_init (to, expr, complain); + if (expr == error_mark_node) + return NULL; + from = TREE_TYPE (expr); + } + if (TREE_CODE (to) == REFERENCE_TYPE) conv = reference_binding (to, from, expr, c_cast_p, flags, complain); else |