re PR fortran/38936 ([F03] ASSOCIATE construct / improved SELECT TYPE (a=>expr))

2010-10-12  Daniel Kraft  <d@domob.eu>

	PR fortran/38936
	* parse.c (parse_associate): Set typespec of associate-name if that of
	the target is already available.

2010-10-12  Daniel Kraft  <d@domob.eu>

	PR fortran/38936
	* gfortran.dg/associate_1.f03: More tests with derived-types.
	* gfortran.dg/associate_9.f03: New test (XFAIL for now).
	* gfortran.dg/associate_8.f03: Fix typo.
	* gfortran.dg/initialization_27.f90: Fix typo.

From-SVN: r165378
This commit is contained in:
Daniel Kraft 2010-10-12 15:30:53 +02:00 committed by Daniel Kraft
parent f166413ae0
commit a81f4b6785
7 changed files with 76 additions and 3 deletions

View file

@ -1,3 +1,9 @@
2010-10-12 Daniel Kraft <d@domob.eu>
PR fortran/38936
* parse.c (parse_associate): Set typespec of associate-name if that of
the target is already available.
2010-10-10 Janus Weil <janus@gcc.gnu.org>
PR fortran/45961

View file

@ -3237,6 +3237,13 @@ parse_associate (void)
sym->assoc = a;
sym->declared_at = a->where;
gfc_set_sym_referenced (sym);
/* Initialize the typespec. It is not available in all cases,
however, as it may only be set on the target during resolution.
Still, sometimes it helps to have it right now -- especially
for parsing component references on the associate-name
in case of assication to a derived-type. */
sym->ts = a->target->ts;
}
accept_statement (ST_ASSOCIATE);

View file

@ -1,3 +1,11 @@
2010-10-12 Daniel Kraft <d@domob.eu>
PR fortran/38936
* gfortran.dg/associate_1.f03: More tests with derived-types.
* gfortran.dg/associate_9.f03: New test (XFAIL for now).
* gfortran.dg/associate_8.f03: Fix typo.
* gfortran.dg/initialization_27.f90: Fix typo.
2010-10-12 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR testsuite/45851

View file

@ -76,9 +76,10 @@ PROGRAM main
! Association to derived type and component.
tp = myt (1)
ASSOCIATE (x => tp, y => tp%comp)
! FIXME: Parsing of derived-type associate names, tests with x.
IF (x%comp /= 1) CALL abort ()
IF (y /= 1) CALL abort ()
y = 5
IF (x%comp /= 5) CALL abort ()
END ASSOCIATE
IF (tp%comp /= 5) CALL abort ()

View file

@ -1,4 +1,4 @@
! { dg-do run}
! { dg-do run }
! { dg-options "-std=f2003 -fall-intrinsics" }
! PR fortran/38936

View file

@ -0,0 +1,51 @@
! { dg-do compile }
! { dg-options "-std=f2003 -fall-intrinsics" }
! FIXME: Change into run test and remove excess error expectation.
! PR fortran/38936
! Association to derived-type, where the target type is not know
! during parsing (only resolution).
! Contributed by Daniel Kraft, d@domob.eu.
MODULE m
IMPLICIT NONE
TYPE :: mynum
INTEGER :: comp
END TYPE mynum
INTERFACE OPERATOR(+)
MODULE PROCEDURE add
END INTERFACE OPERATOR(+)
CONTAINS
PURE FUNCTION add (a, b)
TYPE(mynum), INTENT(IN) :: a, b
TYPE(mynum) :: add
add%comp = a%comp + b%comp
END FUNCTION add
END MODULE m
PROGRAM main
USE :: m
IMPLICIT NONE
TYPE(mynum) :: a
a = mynum (5)
ASSOCIATE (x => add (a, a))
IF (x%comp /= 10) CALL abort ()
END ASSOCIATE
ASSOCIATE (x => a + a)
IF (x%comp /= 10) CALL abort ()
END ASSOCIATE
END PROGRAM main
! { dg-excess-errors "Syntex error in IF" }
! { dg-final { cleanup-modules "m" } }

View file

@ -1,4 +1,4 @@
! { dg-do run}
! { dg-do run }
!
! PR fortran/45489
!