From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10600 invoked by alias); 13 Dec 2010 17:32:37 -0000 Received: (qmail 10583 invoked by uid 22791); 13 Dec 2010 17:32:36 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 13 Dec 2010 17:32:31 +0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/46371] [Coarray] [OOP] SELECT TYPE: scalar coarray variable is rejected X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Mon, 13 Dec 2010 17:32:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2010-12/txt/msg01446.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46371 --- Comment #1 from Tobias Burnus 2010-12-13 17:32:22 UTC --- (In reply to comment #0) > type(foo), allocatable :: o_foo[:] That should be "CLASS(foo)" - sorry for the typo. TODO: a) There is a gfc_is_coindexed() check missing for ASSOCIATE and SELECT TYPE, cf. link and "1 INVALID" part of comment 0 b) "2 VALID" and "3 VALID" do not work: j = a[1]%i 1 Error: Coarray designator at (1) but '__tmp_type_foo' is not a coarray I think at least "attr.codimension" needs to be added during match time - resolve time it too late. The variable is generated at select_type_set_tmp. I tried the following (cf. select_type_set_tmp part of the patch), which does not seem to be sufficient - though it is enough to trigger the issue in resolve.c (cf. resolve.c part of the patch). diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index 44da1bb..6521e79 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -4531,6 +4531,8 @@ select_type_set_tmp (gfc_typespec *ts) &tmp->n.sym->as, false); tmp->n.sym->attr.class_ok = 1; } + if (select_type_stack->selector->attr.codimension) + tmp->n.sym->attr.codimension = 1; tmp->n.sym->attr.select_type_temporary = 1; /* Add an association for it, so the rest of the parser knows it is @@ -4591,8 +4593,14 @@ gfc_match_select_type (void) if (m != MATCH_YES) goto cleanup; - /* Check for F03:C811. */ - if (!expr2 && (expr1->expr_type != EXPR_VARIABLE || expr1->ref != NULL)) + /* Check for F03:C811. Special case: scalar coarray. */ + if (!expr2 && (expr1->expr_type != EXPR_VARIABLE + || (expr1->ref != NULL + && (expr1->ref->next != NULL + || expr1->ref->type != REF_ARRAY + || expr1->ref->u.ar.type != AR_FULL + || expr1->ref->u.ar.dimen != 0 + || expr1->ref->u.ar.codimen != 0)))) { gfc_error ("Selector in SELECT TYPE at %C is not a named variable; " "use associate-name=>"); diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index a27fe2d..5102aea 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -12121,6 +12121,7 @@ resolve_symbol (gfc_symbol *sym) if (((sym->ts.type == BT_DERIVED && sym->ts.u.derived->attr.coarray_comp) || sym->attr.codimension) && !(sym->attr.allocatable || sym->attr.dummy || sym->attr.save + || sym->attr.select_type_temporary || sym->ns->proc_name->attr.flavor == FL_MODULE || sym->ns->proc_name->attr.is_main_program || sym->attr.function || sym->attr.result || sym->attr.use_assoc))