Bug 52013 - [OOP] Polymorphism and coarrays: Support as class container
Summary: [OOP] Polymorphism and coarrays: Support as class container
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2012-01-26 23:20 UTC by Tobias Burnus
Modified: 2012-01-31 19:01 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 2012-01-26 23:20:18 UTC
Currently, the codimension is ignored in the class container.

Result: accepts-invalid, wrong-code, and ICE.


Example for the former; using coarray dummies in elemental procs is invalid:

type t
end type t
contains
  elemental subroutine f(x) 
    class(t), intent(inout) :: x ! Valid
  end subroutine
  elemental subroutine g(y)
    class(t), intent(inout) :: y[*] ! Invalid, but not diagnosed
  end subroutine
end
Comment 1 Tobias Burnus 2012-01-30 13:57:12 UTC
Untested patch. Note: It will change the ABI for GCC 4.6 programs, but only if the used module and type names are together > 47 characters long. 

It will also change the ABI for polymorphic arrays (4.7 feature), thus, it should go in before 4.7 is released.


--- class.c     (revision 183722)
+++ class.c     (working copy)
@@ -296,4 +296,6 @@ get_unique_hashed_string (char *string,
   /* If string is too long, use hash value in hex representation (allow for
-     extra decoration, cf. gfc_build_class_symbol & gfc_find_derived_vtab).  */
-  if (strlen (tmp) > GFC_MAX_SYMBOL_LEN - 11)
+     extra decoration, cf. gfc_build_class_symbol & gfc_find_derived_vtab).
+     We need space to for 15 characters "__class_" + symbol name + "_%d_%da",
+     where %d is the (co)rank which can be up to n = 15. */
+  if (strlen (tmp) > GFC_MAX_SYMBOL_LEN - 15)
     {
@@ -362,6 +364,6 @@ gfc_build_class_symbol (gfc_typespec *ts
   get_unique_hashed_string (tname, ts->u.derived);
-  if ((*as) && (*as)->rank && attr->allocatable)
-    sprintf (name, "__class_%s_%d_a", tname, (*as)->rank);
-  else if ((*as) && (*as)->rank)
-    sprintf (name, "__class_%s_%d", tname, (*as)->rank);
+  if ((*as) && attr->allocatable)
+    sprintf (name, "__class_%s_%d_%da", tname, (*as)->rank, (*as)->corank);
+  else if ((*as))
+    sprintf (name, "__class_%s_%d_%d", tname, (*as)->rank, (*as)->corank);
   else if (attr->pointer)
Comment 2 Tobias Burnus 2012-01-31 18:36:45 UTC
Author: burnus
Date: Tue Jan 31 18:36:40 2012
New Revision: 183769

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183769
Log:
2012-01-31  Tobias Burnus  <burnus@net-b.de>

        PR fortran/52013
        * class.c (get_unique_hashed_string): Adapt trim length.
        (gfc_build_class_symbol) Encode also corank in the container name.

2012-01-31  Tobias Burnus  <burnus@net-b.de>

        PR fortran/52013


Added:
    trunk/gcc/testsuite/gfortran.dg/elemental_args_check_6.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/class.c
    trunk/gcc/testsuite/ChangeLog
Comment 3 Tobias Burnus 2012-01-31 19:01:31 UTC
FIXED on the trunk (4.7).