+2008-04-16 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/35932
+ * trans-intrinsic.c (gfc_conv_intrinsic_char): Even though KIND
+ is not used, the argument must be converted.
+
2008-04-16 Jakub Jelinek <jakub@redhat.com>
PR target/35662
static void
gfc_conv_intrinsic_char (gfc_se * se, gfc_expr * expr)
{
- tree arg;
+ tree arg[2];
tree var;
tree type;
+ unsigned int num_args;
- gfc_conv_intrinsic_function_args (se, expr, &arg, 1);
+ /* We must allow for the KIND argument, even though.... */
+ num_args = gfc_intrinsic_argument_list_length (expr);
+ gfc_conv_intrinsic_function_args (se, expr, arg, num_args);
- /* We currently don't support character types != 1. */
+ /* .... we currently don't support character types != 1. */
gcc_assert (expr->ts.kind == 1);
type = gfc_character1_type_node;
var = gfc_create_var (type, "char");
- arg = convert (type, arg);
- gfc_add_modify_expr (&se->pre, var, arg);
+ arg[0] = convert (type, arg[0]);
+ gfc_add_modify_expr (&se->pre, var, arg[0]);
se->expr = gfc_build_addr_expr (build_pointer_type (type), var);
se->string_length = integer_one_node;
}
--- /dev/null
+! { dg-do run }
+! Tests the fix for PR35932, in which the KIND argument of CHAR
+! was not converted and this screwed up the scalarizer.
+!
+! Contributed by Dick Hendrickson <dick.hendrickson@gmail.com>
+!
+program FA0005
+
+ CHARACTER(1) CDA1(10)
+ character(10) CDA10
+ INTEGER :: IDA(10) = [(i, i = 97,106)]
+
+ CDA1 = CHAR ( IDA, KIND("A" )) !failed
+ if (transfer (CDA1, CDA10) /= "abcdefghij") call abort ()
+ CDA1 = CHAR ( IDA ) !worked
+ if (transfer (CDA1, CDA10) /= "abcdefghij") call abort ()
+END