[Bug fortran/60232] [OOP] The rank of the element in the structure constructor does not match that of the component

2016-11-16 Thread janus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60232

janus at gcc dot gnu.org changed:

   What|Removed |Added

   Target Milestone|--- |4.9.0

[Bug fortran/60232] [OOP] The rank of the element in the structure constructor does not match that of the component

2014-02-19 Thread janus at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60232

--- Comment #5 from janus at gcc dot gnu.org ---
Author: janus
Date: Wed Feb 19 11:52:39 2014
New Revision: 207896

URL: http://gcc.gnu.org/viewcvs?rev=207896root=gccview=rev
Log:
2014-02-19  Janus Weil  ja...@gcc.gnu.org

PR fortran/60232
* expr.c (gfc_get_variable_expr): Don't add REF_ARRAY for dimensionful
functions, which are used as procedure pointer target.


2014-02-19  Janus Weil  ja...@gcc.gnu.org

PR fortran/60232
* gfortran.dg/typebound_proc_33.f90: New.

Added:
trunk/gcc/testsuite/gfortran.dg/typebound_proc_33.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/expr.c
trunk/gcc/testsuite/ChangeLog


[Bug fortran/60232] [OOP] The rank of the element in the structure constructor does not match that of the component

2014-02-19 Thread janus at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60232

janus at gcc dot gnu.org changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #6 from janus at gcc dot gnu.org ---
Fixed on trunk with r207896. Closing.

Thanks for the report!


[Bug fortran/60232] [OOP] The rank of the element in the structure constructor does not match that of the component

2014-02-18 Thread janus at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60232

janus at gcc dot gnu.org changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |janus at gcc dot gnu.org

--- Comment #2 from janus at gcc dot gnu.org ---
This patch fixes the error:


Index: gcc/fortran/resolve.c
===
--- gcc/fortran/resolve.c(revision 207846)
+++ gcc/fortran/resolve.c(working copy)
@@ -1134,8 +1134,6 @@ resolve_structure_cons (gfc_expr *expr, int init)

   for (; comp  cons; comp = comp-next, cons = gfc_constructor_next (cons))
 {
-  int rank;
-
   if (!cons-expr)
 continue;

@@ -1145,15 +1143,18 @@ resolve_structure_cons (gfc_expr *expr, int init)
   continue;
 }

-  rank = comp-as ? comp-as-rank : 0;
-  if (cons-expr-expr_type != EXPR_NULL  rank != cons-expr-rank
-   (comp-attr.allocatable || cons-expr-rank))
+  if (!comp-attr.proc_pointer)
 {
-  gfc_error (The rank of the element in the structure 
- constructor at %L does not match that of the 
- component (%d/%d), cons-expr-where,
- cons-expr-rank, rank);
-  t = false;
+  int rank = comp-as ? comp-as-rank : 0;
+  if (cons-expr-expr_type != EXPR_NULL  rank != cons-expr-rank
+   (comp-attr.allocatable || cons-expr-rank))
+{
+  gfc_error (The rank of the element in the structure 
+constructor at %L does not match that of the 
+component (%d/%d), cons-expr-where,
+cons-expr-rank, rank);
+  t = false;
+}
 }

   /* If we don't have the right type, try to convert it.  */


[Bug fortran/60232] [OOP] The rank of the element in the structure constructor does not match that of the component

2014-02-18 Thread janus at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60232

--- Comment #3 from janus at gcc dot gnu.org ---
I think this patch is even better:

Index: gcc/fortran/expr.c
===
--- gcc/fortran/expr.c(revision 207846)
+++ gcc/fortran/expr.c(working copy)
@@ -3962,9 +3962,10 @@ gfc_get_variable_expr (gfc_symtree *var)
   e-symtree = var;
   e-ts = var-n.sym-ts;

-  if ((var-n.sym-as != NULL  var-n.sym-ts.type != BT_CLASS)
-  || (var-n.sym-ts.type == BT_CLASS  CLASS_DATA (var-n.sym)
-   CLASS_DATA (var-n.sym)-as))
+  if (var-n.sym-attr.flavor != FL_PROCEDURE
+   ((var-n.sym-as != NULL  var-n.sym-ts.type != BT_CLASS)
+   || (var-n.sym-ts.type == BT_CLASS  CLASS_DATA (var-n.sym)
+CLASS_DATA (var-n.sym)-as)))
 {
   e-rank = var-n.sym-ts.type == BT_CLASS
 ? CLASS_DATA (var-n.sym)-as-rank : var-n.sym-as-rank;


[Bug fortran/60232] [OOP] The rank of the element in the structure constructor does not match that of the component

2014-02-18 Thread janus at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60232

--- Comment #4 from janus at gcc dot gnu.org ---
(In reply to janus from comment #3)
 I think this patch is even better:

... and regtests cleanly.


[Bug fortran/60232] [OOP] The rank of the element in the structure constructor does not match that of the component

2014-02-17 Thread janus at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60232

janus at gcc dot gnu.org changed:

   What|Removed |Added

   Keywords||rejects-valid
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2014-02-17
 CC||janus at gcc dot gnu.org
Summary|OOP False Error: The rank   |[OOP] The rank of the
   |of the element in the   |element in the structure
   |structure constructor   |constructor does not match
   ||that of the component
 Ever confirmed|0   |1

--- Comment #1 from janus at gcc dot gnu.org ---
Reduced test case:


module ObjectLists
  implicit none

  Type TObjectList
  contains
procedure :: ArrayItem
  end Type

contains

  function ArrayItem(L) result(P)
Class(TObjectList) :: L
Class(TObjectList), pointer :: P(:)
  end function

end module


  use ObjectLists
  implicit none

  Type, extends(TObjectList):: TSampleList
  end Type

contains

  subroutine TSampleList_ConfidVal(L)
Class(TSampleList) :: L
  end subroutine

end


Same error with 4.7, 4.8 and trunk. (In 4.6 and earlier, polymorphic arrays are
not supported yet.)