* Fix ICE on conditional expression in Ada
@ 2010-07-03 13:15 Eric Botcazou
0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2010-07-03 13:15 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 852 bytes --]
This new Ada 2012 feature is going to stretch the middle-end support for
statement expressions because the front-end can insert arbitrarily complex
statements within the arms of conditional expressions.
The attached testcase triggers an ICE in the tree unsharing phase because we
have a BIND_EXPR under a SAVE_EXPR and we unshare subtrees of SAVE_EXPRs in
Ada (deep unsharing). Fixed by handling BIND_EXPR like SAVE_EXPR/TARGET_EXPR
i.e stopping the unsharing instead of aborting, except with deep unsharing.
This doesn't change anything except for Ada. Tested on i586-suse-linux and
applied on the mainline as obvious.
2010-07-03 Eric Botcazou <ebotcazou@adacore.com>
* gimplify.c (mostly_copy_tree_r): Deal with BIND_EXPR.
2010-07-03 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/cond_expr1.adb: New test.
--
Eric Botcazou
[-- Attachment #2: p.diff --]
[-- Type: text/x-diff, Size: 1055 bytes --]
Index: gimplify.c
===================================================================
--- gimplify.c (revision 161767)
+++ gimplify.c (working copy)
@@ -868,9 +868,9 @@ mostly_copy_tree_r (tree *tp, int *walk_
tree t = *tp;
enum tree_code code = TREE_CODE (t);
- /* Do not copy SAVE_EXPR or TARGET_EXPR nodes themselves, but copy
- their subtrees if we can make sure to do it only once. */
- if (code == SAVE_EXPR || code == TARGET_EXPR)
+ /* Do not copy SAVE_EXPR, TARGET_EXPR or BIND_EXPR nodes themselves, but
+ copy their subtrees if we can make sure to do it only once. */
+ if (code == SAVE_EXPR || code == TARGET_EXPR || code == BIND_EXPR)
{
if (data && !pointer_set_insert ((struct pointer_set_t *)data, t))
;
@@ -895,10 +895,7 @@ mostly_copy_tree_r (tree *tp, int *walk_
/* Leave the bulk of the work to copy_tree_r itself. */
else
- {
- gcc_assert (code != BIND_EXPR);
- copy_tree_r (tp, walk_subtrees, NULL);
- }
+ copy_tree_r (tp, walk_subtrees, NULL);
return NULL_TREE;
}
[-- Attachment #3: cond_expr1.adb --]
[-- Type: text/x-adasrc, Size: 177 bytes --]
-- { dg-do compile }
-- { dg-options "-gnat12" }
function Cond_Expr1 (Dir : in String) return String is
begin
return (if Dir (Dir'Last) = '\' then Dir else Dir & '\');
end;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-07-03 13:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-03 13:15 Fix ICE on conditional expression in Ada Eric Botcazou
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).