From 5af0793001c54632a5160a352cfdee6195338314 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Mon, 18 Apr 2011 07:56:05 +0200 Subject: re PR fortran/18918 (Eventually support Fortran 2008's coarrays [co-arrays]) 2011-04-18 Tobias Burnus PR fortran/18918 * iresolve.c (gfc_resolve_image_index): Set ts.type. * simplify.c (gfc_simplify_image_index): Don't abort if the * bounds are not known at compile time and handle -fcoarray=lib. * trans-intrinsics.c (gfc_conv_intrinsic_function): Handle IMAGE_INDEX. (conv_intrinsic_cobound): Fix comment typo. (trans_this_image): New function. * trans-array.c (gfc_unlikely): Move to trans.c. * trans.c (gfc_unlikely): Function moved from trans-array.c. (gfc_trans_runtime_check): Use it. * trans-io.c (gfc_trans_io_runtime_check): Ditto. * trans.h (gfc_unlikely): Add prototype. 2011-04-18 Tobias Burnus PR fortran/18918 * gfortran.dg/coarray_16.f90: New. From-SVN: r172637 --- gcc/fortran/trans.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'gcc/fortran/trans.c') diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c index 27a352a..9786d97 100644 --- a/gcc/fortran/trans.c +++ b/gcc/fortran/trans.c @@ -505,11 +505,7 @@ gfc_trans_runtime_check (bool error, bool once, tree cond, stmtblock_t * pblock, else cond = fold_convert (long_integer_type_node, cond); - tmp = build_int_cst (long_integer_type_node, 0); - cond = build_call_expr_loc (where->lb->location, - built_in_decls[BUILT_IN_EXPECT], 2, cond, tmp); - cond = fold_convert (boolean_type_node, cond); - + cond = gfc_unlikely (cond); tmp = fold_build3_loc (where->lb->location, COND_EXPR, void_type_node, cond, body, build_empty_stmt (where->lb->location)); @@ -1565,3 +1561,19 @@ gfc_finish_wrapped_block (gfc_wrapped_block* block) return result; } + + +/* Helper function for marking a boolean expression tree as unlikely. */ + +tree +gfc_unlikely (tree cond) +{ + tree tmp; + + cond = fold_convert (long_integer_type_node, cond); + tmp = build_zero_cst (long_integer_type_node); + cond = build_call_expr_loc (input_location, + built_in_decls[BUILT_IN_EXPECT], 2, cond, tmp); + cond = fold_convert (boolean_type_node, cond); + return cond; +} -- cgit v1.1