From 0870d53c5df3fbecd862b72a46d449e6453a8584 Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 5 May 2011 21:02:06 +0000 Subject: [PATCH] PR c++/40975 * tree-inline.c (copy_tree_r): Handle STATEMENT_LIST. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@173452 138bc75d-0d04-0410-961f-82ee72b054a4 index 59ac0f1..1ec4866 100644 new file mode 100644 index 0000000..24582d8 --- /dev/null +++ b/gcc/testsuite/g++.dg/init/new30.C @@ -0,0 +1,15 @@ +// PR c++/40975 + +struct data_type +{ + // constructor required to reproduce compiler bug + data_type() {} +}; + +struct ptr_type +{ + // array new as default argument required to reproduce compiler bug + ptr_type (data_type* ptr = new data_type[1]) { delete[] ptr; } +}; + +ptr_type obj; diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index fd8edb4..f2255f8 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -4334,14 +4334,16 @@ copy_tree_r (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED) CONSTRUCTOR_ELTS (*tp)); *tp = new_tree; } + else if (code == STATEMENT_LIST) + /* We used to just abort on STATEMENT_LIST, but we can run into them + with statement-expressions (c++/40975). */ + copy_statement_list (tp); else if (TREE_CODE_CLASS (code) == tcc_type) *walk_subtrees = 0; else if (TREE_CODE_CLASS (code) == tcc_declaration) *walk_subtrees = 0; else if (TREE_CODE_CLASS (code) == tcc_constant) *walk_subtrees = 0; - else - gcc_assert (code != STATEMENT_LIST); return NULL_TREE; } -- 1.7.0.4