User account creation filtered due to spam.

Bug 46370 - [Coarray] [OOP] ALLOCATE: Error allocating CLASS coarrays
Summary: [Coarray] [OOP] ALLOCATE: Error allocating CLASS coarrays
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 4.6.0
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2010-11-08 14:56 UTC by Tobias Burnus
Modified: 2016-11-16 13:43 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2010-11-08 14:56:44 UTC
Based on the test case at http://j3-fortran.org/doc/meeting/193/10-209r1.txt

The following program (compile with "-fcoarray=single") is rejected with:

allocate (t :: a[*])
                 1
Error: Unexpected coarray designator at (1)


It works with TYPE instead of CLASS.

type t
end type t
class(t), allocatable :: a[:]
allocate (t :: a)
end
Comment 1 Tobias Burnus 2010-12-10 15:10:48 UTC
(In reply to comment #0)

> allocate (t :: a[*])

That's what I wanted to post; not the following:
> allocate (t :: a)

(which is invalid but properly rejected).

The first error is fixed by the following patch. It then stops when checking the constraints C617 and C1229 in "resolve_procedure:" of resolve_variable. ("Polymorphic subobject of coindexed object" -- the message is bogus: There is no subobject - coindexed or not; seemingly, probably the _data component is picked up.)

BTW: In the patch below, one needs to check whether something similar is needed at more places in that function.

--- a/gcc/fortran/primary.c
+++ b/gcc/fortran/primary.c
@@ -1785,3 +1785,7 @@ gfc_match_varspec (gfc_expr *primary, int equiv_flag, bool sub_flag,
       m = gfc_match_array_ref (&tail->u.ar, equiv_flag ? NULL : sym->as,
-                              equiv_flag, sym->as ? sym->as->corank : 0);
+                              equiv_flag,
+                              sym->ts.type == BT_CLASS
+                              ? CLASS_DATA (sym)->as
+                                ? CLASS_DATA (sym)->as->corank : 0
+                              : sym->as ? sym->as->corank : 0);
       if (m != MATCH_YES)
Comment 2 Tobias Burnus 2010-12-11 20:29:01 UTC
Patch: http://gcc.gnu.org/ml/fortran/2010-12/msg00061.html
Comment 3 Tobias Burnus 2010-12-11 22:04:10 UTC
Author: burnus
Date: Sat Dec 11 22:04:06 2010
New Revision: 167715

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=167715
Log:
2010-12-11  Tobias Burnus  <burnus@net-b.de>

        PR fortran/46370
        * primary.c (gfc_match_varspec): Pass information about
        * codimension
        to gfc_match_array_ref also for BT_CLASS.
        * resolve.c (resolve_procedure): Correct check for C612.

2010-12-11  Tobias Burnus  <burnus@net-b.de>

        PR fortran/46370
        * gfortran.dg/coarray_14.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/coarray_14.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/primary.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog
Comment 4 Tobias Burnus 2010-12-11 22:04:42 UTC
FIXED on the 4.6-trunk.