Author: chenr
Date: 2010-10-21 22:53:04 -0400 (Thu, 21 Oct 2010)
New Revision: 3380
Modified:
trunk/osprey/wgen/wgen_expr.cxx
Log:
Fix throwing exception in 3 operands conditional expression.
Approved by JianXin Lai.
Modified: trunk/osprey/wgen/wgen_expr.cxx
===================================================================
--- trunk/osprey/wgen/wgen_expr.cxx 2010-10-20 12:00:35 UTC (rev 3379)
+++ trunk/osprey/wgen/wgen_expr.cxx 2010-10-22 02:53:04 UTC (rev 3380)
@@ -7140,6 +7140,7 @@
WN *then_block = WN_CreateBlock ();
WN *else_block = WN_CreateBlock ();
WN *if_stmt = WN_CreateIf (wn0, then_block, else_block);
+ WN *comma_value = NULL;
#ifdef KEY
SRCPOS if_stmt_srcpos = Get_Srcpos();
// Bug 11937: Generate guard variables where necessary. (See
@@ -7158,6 +7159,7 @@
}
gs_t guard_var1 = WGEN_Guard_Var_Pop();
if (wn1 && !typed_ite) {
+ comma_value = wn1;
wn1 = WN_CreateEval (wn1);
WGEN_Stmt_Append (wn1, Get_Srcpos());
}
@@ -7177,6 +7179,7 @@
wn2 = WGEN_Expand_Expr (gs_tree_operand(exp, 2), FALSE, 0, 0, 0,
0, FALSE, FALSE, target_wn);
gs_t guard_var2 = WGEN_Guard_Var_Pop();
if (wn2 && !typed_ite) {
+ comma_value = wn2;
wn2 = WN_CreateEval (wn2);
WGEN_Stmt_Append (wn2, Get_Srcpos());
}
@@ -7186,8 +7189,18 @@
WGEN_add_guard_var(guard_var2, else_block, FALSE);
}
}
- // Generate IF statement.
- WGEN_Stmt_Append (if_stmt, if_stmt_srcpos);
+
+ if (target_wn == NULL && TY_mtype(ty_idx) != MTYPE_V &&
+ (TY_mtype(ty_idx1) == MTYPE_V || (TY_mtype(ty_idx2) ==
MTYPE_V))) {
+ WN* block = WN_CreateBlock();
+ WN_INSERT_BlockLast(block, if_stmt);
+ wn = WN_CreateComma(OPR_COMMA,
+ TY_mtype(ty_idx1) == MTYPE_V ? TY_mtype(ty_idx2) :
TY_mtype(ty_idx1),
+ MTYPE_V, block, comma_value);
+ } else {
+ // Generate IF statement.
+ WGEN_Stmt_Append (if_stmt, if_stmt_srcpos);
+ }
#else
WGEN_Stmt_Append (if_stmt, Get_Srcpos());
WGEN_Stmt_Push (then_block, wgen_stmk_if_then, Get_Srcpos());
------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Open64-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/open64-devel