Commit c3d0559d by Tobias Schlüter Committed by Tobias Schlüter

re PR fortran/15327 (ICE when using MERGE on strings)

fortran/
PR fortran/15327
* trans-intrinsic.c (gfc_conv_intrinsic_merge): Do the right thing for
strings.

testsuite/
PR fortran/15327
* gfortran.dg/merge_char_1.f90: New test.

From-SVN: r86940
parent 40219f96
2004-09-01 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de> 2004-09-01 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
PR fortran/15327
* trans-intrinsic.c (gfc_conv_intrinsic_merge): Do the right thing for
strings.
2004-09-01 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
PR fortran/16400 PR fortran/16400
PR fortran/16404 PR fortran/16404
(port from g95) (port from g95)
......
...@@ -1998,14 +1998,30 @@ gfc_conv_intrinsic_merge (gfc_se * se, gfc_expr * expr) ...@@ -1998,14 +1998,30 @@ gfc_conv_intrinsic_merge (gfc_se * se, gfc_expr * expr)
tree fsource; tree fsource;
tree mask; tree mask;
tree type; tree type;
tree len;
arg = gfc_conv_intrinsic_function_args (se, expr); arg = gfc_conv_intrinsic_function_args (se, expr);
tsource = TREE_VALUE (arg); if (expr->ts.type != BT_CHARACTER)
arg = TREE_CHAIN (arg); {
fsource = TREE_VALUE (arg); tsource = TREE_VALUE (arg);
arg = TREE_CHAIN (arg); arg = TREE_CHAIN (arg);
mask = TREE_VALUE (arg); fsource = TREE_VALUE (arg);
mask = TREE_VALUE (TREE_CHAIN (arg));
}
else
{
/* We do the same as in the non-character case, but the argument
list is different because of the string length arguments. We
also have to set the string length for the result. */
len = TREE_VALUE (arg);
arg = TREE_CHAIN (arg);
tsource = TREE_VALUE (arg);
arg = TREE_CHAIN (TREE_CHAIN (arg));
fsource = TREE_VALUE (arg);
mask = TREE_VALUE (TREE_CHAIN (arg));
se->string_length = len;
}
type = TREE_TYPE (tsource); type = TREE_TYPE (tsource);
se->expr = fold (build3 (COND_EXPR, type, mask, tsource, fsource)); se->expr = fold (build3 (COND_EXPR, type, mask, tsource, fsource));
} }
......
2004-09-01 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de> 2004-09-01 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
PR fortran/15327
* gfortran.dg/merge_char_1.f90: New test.
2004-09-01 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
PR fortran/16404 PR fortran/16404
* gfortran.dg/der_io_1.f90: XFAIL illegal testcase. * gfortran.dg/der_io_1.f90: XFAIL illegal testcase.
......
! { dg-do run }
! PR 15327
! The merge intrinsic didn't work for strings
character*2 :: c(2)
c = merge( (/ "AA", "BB" /), (/ "CC", "DD" /), (/ .TRUE., .FALSE. /) )
if (c(1).ne."AA" .or. c(2).ne."DD") call abort ()
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment