This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [gfortran,patch] Fix zero-length substrings


Ok, with the change to MAX_EXPR if you like.

Probably one of the quickest review in gfortran history! Thanks Tobias.


Here is what I commited:

Index: trans-expr.c
===================================================================
--- trans-expr.c (revision 114461)
+++ trans-expr.c (working copy)
@@ -275,6 +275,8 @@
build_int_cst (gfc_charlen_type_node, 1),
start.expr);
tmp = fold_build2 (PLUS_EXPR, gfc_charlen_type_node, end.expr, tmp);
+ tmp = fold_build2 (MAX_EXPR, gfc_charlen_type_node, tmp,
+ build_int_cst (gfc_charlen_type_node, 0));
se->string_length = tmp;
}
@@ -2196,6 +2198,7 @@
tree tmp;
tree dsc;
tree ssc;
+ tree cond;
/* Deal with single character specially. */
dsc = gfc_to_single_character (dlen, dest);
@@ -2206,12 +2209,16 @@
return;
}
+ cond = fold_build2 (GT_EXPR, boolean_type_node, dlen,
+ build_int_cst (gfc_charlen_type_node, 0));
+
tmp = NULL_TREE;
tmp = gfc_chainon_list (tmp, dlen);
tmp = gfc_chainon_list (tmp, dest);
tmp = gfc_chainon_list (tmp, slen);
tmp = gfc_chainon_list (tmp, src);
tmp = build_function_call_expr (gfor_fndecl_copy_string, tmp);
+ tmp = fold_build3 (COND_EXPR, void_type_node, cond, tmp, build_empty_stmt ());
gfc_add_expr_to_block (block, tmp);
}



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]