public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/60255] New: Deferred character length variable at (1) cannot yet be associated with unlimited polymorphic entities
@ 2014-02-18  0:03 antony at cosmologist dot info
  2014-02-18  2:00 ` [Bug fortran/60255] " kargl at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: antony at cosmologist dot info @ 2014-02-18  0:03 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 60255
           Summary: Deferred character length variable at (1) cannot yet
                    be associated with unlimited polymorphic entities
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: antony at cosmologist dot info

Created attachment 32157
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32157&action=edit
OOP module with derived TStringList implementing list of strings

Attached file gives multiple repeated errors

ObjectLists2.f90:818.26:

    end module ObjectLists
                          1
Error: TODO: Deferred character length variable at (1) cannot yet be associated
with unlimited polymorphic entities


It should surely give a line number of the error rather than end of module
(currently very hard to workaround as origin of error is unclear). Better,
actually compile (tested valid in ifort 14).


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

* [Bug fortran/60255] Deferred character length variable at (1) cannot yet be associated with unlimited polymorphic entities
  2014-02-18  0:03 [Bug fortran/60255] New: Deferred character length variable at (1) cannot yet be associated with unlimited polymorphic entities antony at cosmologist dot info
@ 2014-02-18  2:00 ` kargl at gcc dot gnu.org
  2014-02-18  9:09 ` janus at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: kargl at gcc dot gnu.org @ 2014-02-18  2:00 UTC (permalink / raw)
  To: gcc-bugs

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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
                 CC|                            |kargl at gcc dot gnu.org
           Severity|major                       |normal

--- Comment #1 from kargl at gcc dot gnu.org ---
Unless a Fortran bug breaks bootstrap, it has an importance of at most normal.


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

* [Bug fortran/60255] Deferred character length variable at (1) cannot yet be associated with unlimited polymorphic entities
  2014-02-18  0:03 [Bug fortran/60255] New: Deferred character length variable at (1) cannot yet be associated with unlimited polymorphic entities antony at cosmologist dot info
  2014-02-18  2:00 ` [Bug fortran/60255] " kargl at gcc dot gnu.org
@ 2014-02-18  9:09 ` janus at gcc dot gnu.org
  2014-02-18 14:20 ` janus at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: janus at gcc dot gnu.org @ 2014-02-18  9:09 UTC (permalink / raw)
  To: gcc-bugs

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

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |janus at gcc dot gnu.org

--- Comment #2 from janus at gcc dot gnu.org ---
The error message comes from find_intrinsic_vtab, to which we'd have to pass a
locus in order to show a proper line number. Currently we use
gfc_current_locus, which is no good since the error happens during resolution.

Also I think the 'TODO' is not suitable here: It is meant for the developer and
not the user, and as such belongs in the source code and not into an error
message.

What does it actually take to make this feature work? Simply removing the error
and using internally charlen=0 to identify deferred length makes the test
module compile:


Index: class.c
===================================================================
--- class.c    (revision 207836)
+++ class.c    (working copy)
@@ -2404,18 +2404,9 @@ find_intrinsic_vtab (gfc_typespec *ts)
   gfc_symbol *copy = NULL, *src = NULL, *dst = NULL;
   int charlen = 0;

-  if (ts->type == BT_CHARACTER)
-    {
-      if (ts->deferred)
-    {
-      gfc_error ("TODO: Deferred character length variable at %C cannot "
-             "yet be associated with unlimited polymorphic entities");
-      return NULL;
-    }
-      else if (ts->u.cl && ts->u.cl->length
-           && ts->u.cl->length->expr_type == EXPR_CONSTANT)
-    charlen = mpz_get_si (ts->u.cl->length->value.integer);
-    }
+  if (ts->type == BT_CHARACTER && !ts->deferred && ts->u.cl &&
ts->u.cl->length
+      && ts->u.cl->length->expr_type == EXPR_CONSTANT)
+    charlen = mpz_get_si (ts->u.cl->length->value.integer);

   /* Find the top-level namespace.  */
   for (ns = gfc_current_ns; ns; ns = ns->parent)



Apparently we do not handle any non-constant string lengths currently. I guess
all of those should either be rejected (like deferred lengths) or we should
just make them work.


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

* [Bug fortran/60255] Deferred character length variable at (1) cannot yet be associated with unlimited polymorphic entities
  2014-02-18  0:03 [Bug fortran/60255] New: Deferred character length variable at (1) cannot yet be associated with unlimited polymorphic entities antony at cosmologist dot info
  2014-02-18  2:00 ` [Bug fortran/60255] " kargl at gcc dot gnu.org
  2014-02-18  9:09 ` janus at gcc dot gnu.org
@ 2014-02-18 14:20 ` janus at gcc dot gnu.org
  2014-02-19 10:06 ` dominiq at lps dot ens.fr
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: janus at gcc dot gnu.org @ 2014-02-18 14:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from janus at gcc dot gnu.org ---
Consider the following simple test case:


implicit none
call sub1("test")
call sub2()

contains

  subroutine sub1(dcl)   ! accepted
    character(len=*), target :: dcl
    class(*), pointer :: ucp

    ucp => dcl

    select type (ucp)
    type is (character(len=*))
      print *,"char"
    type is (real)
      print *,"real"
    class default
      print *,"something else"
    end select

  end subroutine


  subroutine sub2   ! rejected
    character(len=:), allocatable, target :: dcl
    class(*), pointer :: ucp

    dcl = "ttt"
    ucp => dcl

    select type (ucp)
    type is (character(len=*))
      print *,"char"
    type is (real)
      print *,"real"
    class default
      print *,"something else"
    end select

  end subroutine

end


While 'sub1' is currently accepted (with unpatched trunk) and shows the right
runtime behavior, 'sub2' is rejected with the error of comment 0.

With the patch in comment 2, both cases are accepted and show the right runtime
behavior.

The only potential problem I can see is that the '_size' component of the vtab
is zero and does not reflect its actual size.


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

* [Bug fortran/60255] Deferred character length variable at (1) cannot yet be associated with unlimited polymorphic entities
  2014-02-18  0:03 [Bug fortran/60255] New: Deferred character length variable at (1) cannot yet be associated with unlimited polymorphic entities antony at cosmologist dot info
                   ` (2 preceding siblings ...)
  2014-02-18 14:20 ` janus at gcc dot gnu.org
@ 2014-02-19 10:06 ` dominiq at lps dot ens.fr
  2014-02-19 12:08 ` janus at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-02-19 10:06 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-02-19
     Ever confirmed|0                           |1


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

* [Bug fortran/60255] Deferred character length variable at (1) cannot yet be associated with unlimited polymorphic entities
  2014-02-18  0:03 [Bug fortran/60255] New: Deferred character length variable at (1) cannot yet be associated with unlimited polymorphic entities antony at cosmologist dot info
                   ` (3 preceding siblings ...)
  2014-02-19 10:06 ` dominiq at lps dot ens.fr
@ 2014-02-19 12:08 ` janus at gcc dot gnu.org
  2014-02-27 14:30 ` antony at cosmologist dot info
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: janus at gcc dot gnu.org @ 2014-02-19 12:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from janus at gcc dot gnu.org ---
Antony, is it possible for you to try the patch in comment 2, in order to check
if it produces the expected runtime behavior for your code?


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

* [Bug fortran/60255] Deferred character length variable at (1) cannot yet be associated with unlimited polymorphic entities
  2014-02-18  0:03 [Bug fortran/60255] New: Deferred character length variable at (1) cannot yet be associated with unlimited polymorphic entities antony at cosmologist dot info
                   ` (4 preceding siblings ...)
  2014-02-19 12:08 ` janus at gcc dot gnu.org
@ 2014-02-27 14:30 ` antony at cosmologist dot info
  2015-01-18 22:02 ` [Bug fortran/60255] [OOP] " pault at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: antony at cosmologist dot info @ 2014-02-27 14:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Antony Lewis <antony at cosmologist dot info> ---
The patch generated a SIGSEGV in test code (which works with ifort), but could
be another unrelated issue.


Here's another simple test case for the original issue:


program test
    character(LEN=:), allocatable :: S
    call subP(S)
contains

subroutine subP(P)
    class(*) :: P
end subroutine

end program


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

* [Bug fortran/60255] [OOP] Deferred character length variable at (1) cannot yet be associated with unlimited polymorphic entities
  2014-02-18  0:03 [Bug fortran/60255] New: Deferred character length variable at (1) cannot yet be associated with unlimited polymorphic entities antony at cosmologist dot info
                   ` (5 preceding siblings ...)
  2014-02-27 14:30 ` antony at cosmologist dot info
@ 2015-01-18 22:02 ` pault at gcc dot gnu.org
  2015-01-23 10:56 ` vehre at gmx dot de
  2015-03-23 12:57 ` vehre at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: pault at gcc dot gnu.org @ 2015-01-18 22:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60255

--- Comment #7 from Paul Thomas <pault at gcc dot gnu.org> ---
Author: pault
Date: Sun Jan 18 22:01:29 2015
New Revision: 219827

URL: https://gcc.gnu.org/viewcvs?rev=219827&root=gcc&view=rev
Log:
2015-01-18  Andre Vehreschild  <vehre@gmx.de>
        Janus Weil <janus@gcc.gnu.org>

    PR fortran/60255
    * class.c (gfc_get_len_component): New.
    (gfc_build_class_symbol): Add _len component to unlimited
    polymorphic entities.
    (find_intrinsic_vtab): Removed emitting of error message.
    * gfortran.h: Added prototype for gfc_get_len_component.
    * simplify.c (gfc_simplify_len): Use _len component where
    available.
    * trans-expr.c (gfc_class_len_get): New.
    (gfc_conv_intrinsic_to_class): Add handling for deferred
    character arrays.
    (gfc_conv_structure): Treat _len component correctly.
    (gfc_conv_expr): Prevent bind_c handling when not required.
    (gfc_trans_pointer_assignment): Propagate _len component.
    * trans-stmt.c (class_has_len_component): New.
    (trans_associate_var): _len component treatment for associate
    context.
    (gfc_trans_allocate): Same as for trans_associate_var()
    * trans.h: Added prototype for gfc_class_len_get.

2015-01-18  Andre Vehreschild  <vehre@gmx.de>

    PR fortran/60255
    * gfortran.dg/unlimited_polymorphic_2.f03: Removed error.
    * gfortran.dg/unlimited_polymorphic_20.f03: New test.

2015-01-18  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/64578
    * gfortran.dg/unlimited_polymorphic_21.f90: New test

Added:
    trunk/gcc/testsuite/gfortran.dg/unlimited_polymorphic_20.f90
    trunk/gcc/testsuite/gfortran.dg/unlimited_polymorphic_21.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/class.c
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/simplify.c
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/fortran/trans-stmt.c
    trunk/gcc/fortran/trans.h
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/unlimited_polymorphic_2.f03


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

* [Bug fortran/60255] [OOP] Deferred character length variable at (1) cannot yet be associated with unlimited polymorphic entities
  2014-02-18  0:03 [Bug fortran/60255] New: Deferred character length variable at (1) cannot yet be associated with unlimited polymorphic entities antony at cosmologist dot info
                   ` (6 preceding siblings ...)
  2015-01-18 22:02 ` [Bug fortran/60255] [OOP] " pault at gcc dot gnu.org
@ 2015-01-23 10:56 ` vehre at gmx dot de
  2015-03-23 12:57 ` vehre at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: vehre at gmx dot de @ 2015-01-23 10:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60255

Andre Vehreschild <vehre at gmx dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
            Version|4.9.0                       |5.0
         Resolution|---                         |FIXED

--- Comment #8 from Andre Vehreschild <vehre at gmx dot de> ---
Fixed with r219827.


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

* [Bug fortran/60255] [OOP] Deferred character length variable at (1) cannot yet be associated with unlimited polymorphic entities
  2014-02-18  0:03 [Bug fortran/60255] New: Deferred character length variable at (1) cannot yet be associated with unlimited polymorphic entities antony at cosmologist dot info
                   ` (7 preceding siblings ...)
  2015-01-23 10:56 ` vehre at gmx dot de
@ 2015-03-23 12:57 ` vehre at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: vehre at gcc dot gnu.org @ 2015-03-23 12:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60255

--- Comment #9 from vehre at gcc dot gnu.org ---
Author: vehre
Date: Mon Mar 23 11:58:49 2015
New Revision: 221591

URL: https://gcc.gnu.org/viewcvs?rev=221591&root=gcc&view=rev
Log:
gcc/fortran/ChangeLog

2015-03-23  Andre Vehreschild  <vehre@gmx.de>
        Janus Weil  <janus@gcc.gnu.org>

    Backported from mainline
    PR fortran/60255
    Initial patch version: Janus Weil
    * class.c (gfc_get_len_component): New.
    (gfc_build_class_symbol): Add _len component to unlimited
    polymorphic entities.
    (find_intrinsic_vtab): Removed emitting of error message.
    * gfortran.h: Added prototype for gfc_get_len_component.
    * simplify.c (gfc_simplify_len): Use _len component where
    available.
    * trans-expr.c (gfc_class_len_get): New.
    (gfc_conv_intrinsic_to_class): Add handling for deferred
    character arrays.
    (gfc_conv_structure): Treat _len component correctly.
    (gfc_conv_expr): Prevent bind_c handling when not required.
    (gfc_trans_pointer_assignment): Propagate _len component.
    * trans-stmt.c (class_has_len_component): New.
    (trans_associate_var): _len component treatement for associate
    context.
    (gfc_trans_allocate): Same as for trans_associate_var()
    * trans.h: Add prototype for gfc_class_len_get.

gcc/testsuite/ChangeLog

2015-03-20  Andre Vehreschild  <vehre@gmx.de>

    Backport from mainline
    PR fortran/60255
    * gfortran.dg/unlimited_polymorphic_2.f03: Removed error.
    Converted from dos to unix line endings.
    * gfortran.dg/unlimited_polymorphic_20.f03: New test.


Added:
   
branches/gcc-4_9-branch/gcc/testsuite/gfortran.dg/unlimited_polymorphic_20.f03
Modified:
    branches/gcc-4_9-branch/gcc/fortran/ChangeLog
    branches/gcc-4_9-branch/gcc/fortran/class.c
    branches/gcc-4_9-branch/gcc/fortran/gfortran.h
    branches/gcc-4_9-branch/gcc/fortran/simplify.c
    branches/gcc-4_9-branch/gcc/fortran/trans-expr.c
    branches/gcc-4_9-branch/gcc/fortran/trans-stmt.c
    branches/gcc-4_9-branch/gcc/fortran/trans.h
    branches/gcc-4_9-branch/gcc/testsuite/ChangeLog
   
branches/gcc-4_9-branch/gcc/testsuite/gfortran.dg/unlimited_polymorphic_2.f03


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

end of thread, other threads:[~2015-03-23 11:59 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-18  0:03 [Bug fortran/60255] New: Deferred character length variable at (1) cannot yet be associated with unlimited polymorphic entities antony at cosmologist dot info
2014-02-18  2:00 ` [Bug fortran/60255] " kargl at gcc dot gnu.org
2014-02-18  9:09 ` janus at gcc dot gnu.org
2014-02-18 14:20 ` janus at gcc dot gnu.org
2014-02-19 10:06 ` dominiq at lps dot ens.fr
2014-02-19 12:08 ` janus at gcc dot gnu.org
2014-02-27 14:30 ` antony at cosmologist dot info
2015-01-18 22:02 ` [Bug fortran/60255] [OOP] " pault at gcc dot gnu.org
2015-01-23 10:56 ` vehre at gmx dot de
2015-03-23 12:57 ` vehre at gcc dot gnu.org

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).