Commit 636da744 by Paul Thomas

re PR fortran/24813 (ICE with scalarization LEN of character types)

2006-05-07  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/24813
	* trans-array.c (get_array_ctor_strlen): Remove static attribute.
	* trans.h: Add prototype for get_array_ctor_strlen.
	* trans-intrinsic.c (gfc_conv_intrinsic_len): Switch on EXPR_ARRAY
	and call get_array_ctor_strlen.

2006-05-07  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/24813
	* gfortran.dg/char_cons_len_1.f90: New test.

From-SVN: r113594
parent 8f988653
2006-05-07 Paul Thomas <pault@gcc.gnu.org>
PR fortran/24813
* trans-array.c (get_array_ctor_strlen): Remove static attribute.
* trans.h: Add prototype for get_array_ctor_strlen.
* trans-intrinsic.c (gfc_conv_intrinsic_len): Switch on EXPR_ARRAY
and call get_array_ctor_strlen.
2006-05-05 Steven G. Kargl <kargls@comcast.net> 2006-05-05 Steven G. Kargl <kargls@comcast.net>
* invoke.texi: Update description of -fall-intrinsics * invoke.texi: Update description of -fall-intrinsics
......
...@@ -1328,7 +1328,7 @@ get_array_ctor_var_strlen (gfc_expr * expr, tree * len) ...@@ -1328,7 +1328,7 @@ get_array_ctor_var_strlen (gfc_expr * expr, tree * len)
/* Figure out the string length of a character array constructor. /* Figure out the string length of a character array constructor.
Returns TRUE if all elements are character constants. */ Returns TRUE if all elements are character constants. */
static bool bool
get_array_ctor_strlen (gfc_constructor * c, tree * len) get_array_ctor_strlen (gfc_constructor * c, tree * len)
{ {
bool is_const; bool is_const;
......
...@@ -2258,6 +2258,13 @@ gfc_conv_intrinsic_len (gfc_se * se, gfc_expr * expr) ...@@ -2258,6 +2258,13 @@ gfc_conv_intrinsic_len (gfc_se * se, gfc_expr * expr)
len = build_int_cst (NULL_TREE, arg->value.character.length); len = build_int_cst (NULL_TREE, arg->value.character.length);
break; break;
case EXPR_ARRAY:
/* Obtain the string length from the function used by
trans-array.c(gfc_trans_array_constructor). */
len = NULL_TREE;
get_array_ctor_strlen (arg->value.constructor, &len);
break;
default: default:
if (arg->expr_type == EXPR_VARIABLE if (arg->expr_type == EXPR_VARIABLE
&& (arg->ref == NULL || (arg->ref->next == NULL && (arg->ref == NULL || (arg->ref->next == NULL
......
...@@ -419,6 +419,9 @@ void gfc_get_backend_locus (locus *); ...@@ -419,6 +419,9 @@ void gfc_get_backend_locus (locus *);
extern GTY(()) tree gfc_static_ctors; extern GTY(()) tree gfc_static_ctors;
void gfc_generate_constructors (void); void gfc_generate_constructors (void);
/* Get the string length of an array constructor. */
bool get_array_ctor_strlen (gfc_constructor *, tree *);
/* Generate a runtime error check. */ /* Generate a runtime error check. */
void gfc_trans_runtime_check (tree, tree, stmtblock_t *); void gfc_trans_runtime_check (tree, tree, stmtblock_t *);
......
2006-05-07 Paul Thomas <pault@gcc.gnu.org>
PR fortran/24813
* gfortran.dg/char_cons_len_1.f90: New test.
2006-05-06 Volker Reichelt <reichelt@igpm.rwth-aachen.de> 2006-05-06 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/27427 PR c++/27427
! { dg-do compile }
! Tests the fix for PR24813 in which a character array
! constructor, as an argument for LEN, would cause an ICE.
!
character(11) :: chr1, chr2
i = len ((/chr1, chr2, "ggg"/))
j = len ((/"abcdefghijk", chr1, chr2/))
k = len ((/'hello ','goodbye'/))
l = foo ("yes siree, Bob")
if (any ((/11,11,7,14/) /= (/i,j,k,l/))) call abort ()
contains
integer function foo (arg)
character(*) :: arg
character(len(arg)) :: ctor
foo = len ((/ctor/))
end function foo
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