+2015-01-18 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/55901
+ * primary.c (gfc_match_varspec): Exclude dangling associate-
+ names with dimension 0 from being counted as arrays.
+ * resolve.c (resolve_assoc_var): Sub-strings are permissible
+ for associate-names, so exclude characters from the test for
+ misuse as arrays.
+ * trans-decl.c (gfc_get_symbol_decl): Associate-names can use
+ the hidden string length variable of their associated target.
+ Signal this by setting 'length' to a constant, if the decl for
+ the string length is a variable.
+
2015-01-17 Paul Thomas <pault@gcc.gnu.org>
PR fortran/64578
Thus if we have one and parentheses follow, we have to assume that it
actually is one for now. The final decision will be made at
resolution time, of course. */
- if (sym->assoc && gfc_peek_ascii_char () == '(')
+ if (sym->assoc && gfc_peek_ascii_char () == '('
+ && !(sym->assoc->dangling && sym->assoc->st
+ && sym->assoc->st->n.sym
+ && sym->assoc->st->n.sym->attr.dimension == 0))
sym->attr.dimension = 1;
if ((equiv_flag && gfc_peek_ascii_char () == '(')
/* Finally resolve if this is an array or not. */
if (sym->attr.dimension && target->rank == 0)
{
- gfc_error ("Associate-name %qs at %L is used as array",
- sym->name, &sym->declared_at);
+ /* primary.c makes the assumption that a reference to an associate
+ name followed by a left parenthesis is an array reference. */
+ if (sym->ts.type != BT_CHARACTER)
+ gfc_error ("Associate-name %qs at %L is used as array",
+ sym->name, &sym->declared_at);
sym->attr.dimension = 0;
return;
}
gfc_internal_error ("intrinsic variable which isn't a procedure");
/* Create string length decl first so that they can be used in the
- type declaration. */
+ type declaration. For associate names, the target character
+ length is used. Set 'length' to a constant so that if the
+ string lenght is a variable, it is not finished a second time. */
if (sym->ts.type == BT_CHARACTER)
- length = gfc_create_string_length (sym);
+ {
+ if (sym->attr.associate_var
+ && sym->ts.u.cl->backend_decl
+ && TREE_CODE (sym->ts.u.cl->backend_decl) == VAR_DECL)
+ length = gfc_index_zero_node;
+ else
+ length = gfc_create_string_length (sym);
+ }
/* Create the decl for the variable. */
decl = build_decl (sym->declared_at.lb->location,
/* Character variables need special handling. */
gfc_allocate_lang_decl (decl);
+ /* Associate names can use the hidden string length variable
+ of their associated target. */
if (TREE_CODE (length) != INTEGER_CST)
{
gfc_finish_var_decl (length, sym);
+2015-01-18 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/55901
+ * gfortran.dg/associate_1.f03: Allow test for character with
+ automatic length.
+
2015-01-17 Segher Boessenkool <segher@kernel.crashing.org>
* gcc.target/powerpc/ppc-fpconv-4.c: Skip for -mpowerpc64.
IF (tp%comp /= 5) CALL abort ()
! Association to character variables.
- ! FIXME: Enable character test, once this works.
- !CALL test_char (5)
+ CALL test_char (5)
CONTAINS
func = (/ 1, 3, 5 /)
END FUNCTION func
-#if 0
! Test association to character variable with automatic length.
SUBROUTINE test_char (n)
INTEGER, INTENT(IN) :: n
END ASSOCIATE
IF (str /= "abcde") CALL abort ()
END SUBROUTINE test_char
-#endif
END PROGRAM main