Re: copy_tree_r and STATEMENT_LIST (was Re: C++ PATCHes relating to c++/48834, c++/40975 (array new))

2011-05-07 Thread Eric Botcazou
It seems pretty straightforward to me that a function named copy_tree_r should copy everything that isn't always shared (like decls). It already copies SAVE_EXPR, after all; how is copying STATEMENT_LIST going to cause trouble in a context where copying SAVE_EXPR isn't? OK, this can make

copy_tree_r and STATEMENT_LIST (was Re: C++ PATCHes relating to c++/48834, c++/40975 (array new))

2011-05-05 Thread Jason Merrill
On 05/04/2011 06:57 PM, Eric Botcazou wrote: But you're unilaterally choosing one special handling (copying) among several ones (copying, not copying, aborting) just because of one caller, for no good reason IMO. It seems pretty straightforward to me that a function named copy_tree_r should

Re: C++ PATCHes relating to c++/48834, c++/40975 (array new)

2011-05-04 Thread Eric Botcazou
Well, let's look at the users of copy_tree_r. cp/tree.c (bot_manip): The case I want to fix. Then I'd put the fix there. The old behaviour of copy_tree_r is IMO the most sensible one and its callers should cope, as almost all already do it seems. -- Eric Botcazou

Re: C++ PATCHes relating to c++/48834, c++/40975 (array new)

2011-05-04 Thread Jason Merrill
On 05/04/2011 04:12 AM, Eric Botcazou wrote: Well, let's look at the users of copy_tree_r. cp/tree.c (bot_manip): The case I want to fix. Then I'd put the fix there. The old behaviour of copy_tree_r is IMO the most sensible one and its callers should cope, as almost all already do it seems.

Re: C++ PATCHes relating to c++/48834, c++/40975 (array new)

2011-05-04 Thread Eric Botcazou
Well, I disagree. STATEMENT_LISTs are just another kind of thing you encounter in an expression; if a caller wants special handling, they can arrange for it. But you're unilaterally choosing one special handling (copying) among several ones (copying, not copying, aborting) just because of

Re: C++ PATCHes relating to c++/48834, c++/40975 (array new)

2011-05-03 Thread Eric Botcazou
How is it used in Ada? The front-end doesn't use it directly, it's only used through the gimplifier by the unsharing phase (unshare_body). We also have statement expressions. -- Eric Botcazou

Re: C++ PATCHes relating to c++/48834, c++/40975 (array new)

2011-05-03 Thread Jason Merrill
On 05/03/2011 03:00 AM, Eric Botcazou wrote: How is it used in Ada? The front-end doesn't use it directly, it's only used through the gimplifier by the unsharing phase (unshare_body). We also have statement expressions. In that case you wouldn't be affected by this patch; unshare_body uses

Re: C++ PATCHes relating to c++/48834, c++/40975 (array new)

2011-05-03 Thread Eric Botcazou
In that case you wouldn't be affected by this patch; unshare_body uses mostly_copy_tree_r, which has its own special case for STATEMENT_LIST. Right, I added it precisely to support statement expressions in Ada (instead of changing copy_tree_r) since we never want to copy them in the unsharing

Re: C++ PATCHes relating to c++/48834, c++/40975 (array new)

2011-05-03 Thread Jason Merrill
On 05/03/2011 11:52 AM, Eric Botcazou wrote: In that case you wouldn't be affected by this patch; unshare_body uses mostly_copy_tree_r, which has its own special case for STATEMENT_LIST. Right, I added it precisely to support statement expressions in Ada (instead of changing copy_tree_r) since

C++ PATCHes relating to c++/48834, c++/40975 (array new)

2011-05-02 Thread Jason Merrill
So, the problem in 48834 was that we had specified a particular target for the vec initialization, but it was getting clobbered by ending up on the rhs of an INIT_EXPR. So 48834.patch avoids that. But Diego doesn't think there was any real reason to abort on trying to copy a STATEMENT_LIST,

Re: C++ PATCHes relating to c++/48834, c++/40975 (array new)

2011-05-02 Thread Eric Botcazou
But Diego doesn't think there was any real reason to abort on trying to copy a STATEMENT_LIST, so it seems to me that we could revert my earlier patch for 40975 and just add support for copying STATEMENT_LIST. So 40975-2.patch adds that support. FWIW this assertion caught an impressive

Re: C++ PATCHes relating to c++/48834, c++/40975 (array new)

2011-05-02 Thread Jason Merrill
On 05/02/2011 06:23 PM, Eric Botcazou wrote: I'm not sure you can copy statements if they have any side-effects; this looks quite dangerous to me. Instead statement-expressions should be wrapped up in a SAVE_EXPR/TARGET_EXPR to protect them and prevent copying. It sounds like Ada and C++ are