public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/46371] New: [OOP] SELECT TYPE: scalar coarray variable is rejected
@ 2010-11-08 15:05 burnus at gcc dot gnu.org
  2010-12-13 17:32 ` [Bug fortran/46371] [Coarray] " burnus at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2010-11-08 15:05 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46371

           Summary: [OOP] SELECT TYPE: scalar coarray variable is rejected
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org
                CC: domob@gcc.gnu.org


Example has been taken from the interpretation request at
http://j3-fortran.org/doc/meeting/193/10-209r1.txt ; the IR does not contain a
suggested edits.

The following program, which needs two images at run time is regarded as valid
(with select 1 commented out) - if the ALLOCATE is not commented out. (The
ALLOCATE statement is commented-out because of PR 46370.)


Using gfortran -fcorarray=single, it fails with:

    select type(o_foo)                ! 3 VALID
                                               1
Error: Selector in SELECT TYPE at (1) is not a named variable; use
associate-name=>


module m
  type :: foo
    integer :: i = 0
  end type
end module m
program p
  use m
  type(foo), allocatable :: o_foo[:]
  integer :: j

!  allocate(foo :: o_foo[*])
  if (this_image() == 1) then

!    select type(a => o_foo[2])        ! 1 INVALID
!      type is(foo)
!      j = a%i
!    end select

!    select type(a => o_foo)           ! 2 VALID
!      type is(foo)
!      j = a[2]%i
!   end select

    select type(o_foo)                ! 3 VALID
      type is(foo)
      j = o_foo[2]%i
    end select

  end if
end program p


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/46371] [Coarray] [OOP] SELECT TYPE: scalar coarray variable is rejected
  2010-11-08 15:05 [Bug fortran/46371] New: [OOP] SELECT TYPE: scalar coarray variable is rejected burnus at gcc dot gnu.org
@ 2010-12-13 17:32 ` burnus at gcc dot gnu.org
  2010-12-13 22:14 ` burnus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2010-12-13 17:32 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46371

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 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))


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/46371] [Coarray] [OOP] SELECT TYPE: scalar coarray variable is rejected
  2010-11-08 15:05 [Bug fortran/46371] New: [OOP] SELECT TYPE: scalar coarray variable is rejected burnus at gcc dot gnu.org
  2010-12-13 17:32 ` [Bug fortran/46371] [Coarray] " burnus at gcc dot gnu.org
@ 2010-12-13 22:14 ` burnus at gcc dot gnu.org
  2011-11-24 17:45 ` burnus at gcc dot gnu.org
  2013-12-17  9:17 ` dominiq at lps dot ens.fr
  3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2010-12-13 22:14 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46371

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2010-12-13 22:13:53 UTC ---
Created attachment 22747
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22747
Draft patch

Draft patch fixes "2 VALID" and "3 VALID" - however, I see failures for the
following examples. Additionally, the gfc_is_coindexed check is still missing.

Additional examples:

  class(foo), allocatable :: o_foo(:)
  class(foo), allocatable :: o_bar(:)[:]

! Expected: "o => o_foo" gives an error because of missing "(...)"
! However, it is accepted by NAG and Intel; the gfortran message is strange
!    select type(o => o_foo)                ! 4 INVALID
      type is(foo) ! "must have a deferred shape"
      j = o(1)%i
    end select

   select type(o => o_bar)                ! 5 VALID
     type is(foo)
     j = o(1)[1]%i ! "Unexpected coarray designator"
   end select

   select type(o => o_foo(1))  ! ICE segfault       
     type is(foo)              ! 6 VALID
     j = o%i
   end select


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/46371] [Coarray] [OOP] SELECT TYPE: scalar coarray variable is rejected
  2010-11-08 15:05 [Bug fortran/46371] New: [OOP] SELECT TYPE: scalar coarray variable is rejected burnus at gcc dot gnu.org
  2010-12-13 17:32 ` [Bug fortran/46371] [Coarray] " burnus at gcc dot gnu.org
  2010-12-13 22:14 ` burnus at gcc dot gnu.org
@ 2011-11-24 17:45 ` burnus at gcc dot gnu.org
  2013-12-17  9:17 ` dominiq at lps dot ens.fr
  3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-11-24 17:45 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46371

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-11-24 16:41:54 UTC ---
Polymorphic array example: Todo check for validity and fix.

program p
  use m
  class(foo), allocatable :: o_bar(:)[:]
  integer :: j

  allocate(foo :: o_bar(5)[*])

  select type(o_bar)
    type is(foo)
      j = o_bar(2)[1]%i
  end select

!! FIXME: "type if (foo)" fails with:
!! Associate-name '__tmp_type_foo' at (1) is used as array
  select type(a => o_bar)
    type is (foo)
      j = a(1)[1]%i
  end select

!! FIXME: "a" should be a rank 0 not a rank 1
!!        array
  select type(a => o_bar(1))
    type is (foo)
      j = a[2]%i
  end select
end program p


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/46371] [Coarray] [OOP] SELECT TYPE: scalar coarray variable is rejected
  2010-11-08 15:05 [Bug fortran/46371] New: [OOP] SELECT TYPE: scalar coarray variable is rejected burnus at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2011-11-24 17:45 ` burnus at gcc dot gnu.org
@ 2013-12-17  9:17 ` dominiq at lps dot ens.fr
  3 siblings, 0 replies; 5+ messages in thread
From: dominiq at lps dot ens.fr @ 2013-12-17  9:17 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46371

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-12-17
     Ever confirmed|0                           |1

--- Comment #4 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Still present at r206026. What happened to the patch?


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-12-17  9:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-08 15:05 [Bug fortran/46371] New: [OOP] SELECT TYPE: scalar coarray variable is rejected burnus at gcc dot gnu.org
2010-12-13 17:32 ` [Bug fortran/46371] [Coarray] " burnus at gcc dot gnu.org
2010-12-13 22:14 ` burnus at gcc dot gnu.org
2011-11-24 17:45 ` burnus at gcc dot gnu.org
2013-12-17  9:17 ` dominiq at lps dot ens.fr

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).