diff options
author | Jason Merrill <jason@redhat.com> | 2011-06-30 20:03:34 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2011-06-30 20:03:34 -0400 |
commit | b9d6b0153cbd3fc5a5d451ffa1a44313ba56e24a (patch) | |
tree | 92d5685f6c5750040df40af7dc5b9a591a5c8bf1 /gcc/cp | |
parent | 1ac93f108375d63eb373fbfcd59634202d1b50b7 (diff) | |
download | gcc-b9d6b0153cbd3fc5a5d451ffa1a44313ba56e24a.zip gcc-b9d6b0153cbd3fc5a5d451ffa1a44313ba56e24a.tar.gz gcc-b9d6b0153cbd3fc5a5d451ffa1a44313ba56e24a.tar.bz2 |
re PR c++/49355 (new T({""}) crashes G++ when struct T { std::string foobar };)
PR c++/49355
* tree.c (stabilize_init): Handle aggregate initialization.
From-SVN: r175736
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/cp/tree.c | 16 |
2 files changed, 15 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 42c21fe..70b6f77 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2011-06-30 Jason Merrill <jason@redhat.com> + PR c++/49355 + * tree.c (stabilize_init): Handle aggregate initialization. + PR c++/48481 * name-lookup.c (struct arg_lookup): Add fn_set. (add_function): Check it. diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index c50751f..678c7ef 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -3291,10 +3291,18 @@ stabilize_init (tree init, tree *initp) t = TARGET_EXPR_INITIAL (t); if (TREE_CODE (t) == COMPOUND_EXPR) t = expr_last (t); - if (TREE_CODE (t) == CONSTRUCTOR - && EMPTY_CONSTRUCTOR_P (t)) - /* Default-initialization. */ - return true; + if (TREE_CODE (t) == CONSTRUCTOR) + { + /* Aggregate initialization: stabilize each of the field + initializers. */ + unsigned i; + tree value; + bool good = true; + FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (t), i, value) + if (!stabilize_init (value, initp)) + good = false; + return good; + } /* If the initializer is a COND_EXPR, we can't preevaluate anything. */ |