diff options
-rw-r--r-- | gcc/fortran/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fortran/parse.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/associate_1.f03 | 3 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/associate_8.f03 | 2 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/associate_9.f03 | 51 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/initialization_27.f90 | 2 |
7 files changed, 76 insertions, 3 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index f748da6..517b500 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -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 diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c index 268e6af..89ffbaf 100644 --- a/gcc/fortran/parse.c +++ b/gcc/fortran/parse.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5b7c054..a87da8c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 diff --git a/gcc/testsuite/gfortran.dg/associate_1.f03 b/gcc/testsuite/gfortran.dg/associate_1.f03 index 4cb727f..d7b14ae 100644 --- a/gcc/testsuite/gfortran.dg/associate_1.f03 +++ b/gcc/testsuite/gfortran.dg/associate_1.f03 @@ -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 () diff --git a/gcc/testsuite/gfortran.dg/associate_8.f03 b/gcc/testsuite/gfortran.dg/associate_8.f03 index 0c95acb..a6f9938 100644 --- a/gcc/testsuite/gfortran.dg/associate_8.f03 +++ b/gcc/testsuite/gfortran.dg/associate_8.f03 @@ -1,4 +1,4 @@ -! { dg-do run} +! { dg-do run } ! { dg-options "-std=f2003 -fall-intrinsics" } ! PR fortran/38936 diff --git a/gcc/testsuite/gfortran.dg/associate_9.f03 b/gcc/testsuite/gfortran.dg/associate_9.f03 new file mode 100644 index 0000000..13a10fc --- /dev/null +++ b/gcc/testsuite/gfortran.dg/associate_9.f03 @@ -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" } } diff --git a/gcc/testsuite/gfortran.dg/initialization_27.f90 b/gcc/testsuite/gfortran.dg/initialization_27.f90 index 680a457..8e21936 100644 --- a/gcc/testsuite/gfortran.dg/initialization_27.f90 +++ b/gcc/testsuite/gfortran.dg/initialization_27.f90 @@ -1,4 +1,4 @@ -! { dg-do run} +! { dg-do run } ! ! PR fortran/45489 ! |