Bug 51632 - [OOP] Bogus argument checking for generated _def_init parameter and _copy procedure with CAF
Summary: [OOP] Bogus argument checking for generated _def_init parameter and _copy pro...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: 4.8.0
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks: 52403
  Show dependency treegraph
 
Reported: 2011-12-20 07:50 UTC by Tobias Burnus
Modified: 2016-11-16 16:07 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.6.3, 4.7.0
Last reconfirmed: 2015-10-20 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2011-12-20 07:50:49 UTC
The following program is rejected with:

    class(periodic_2nd_order), intent(in) :: this
                                                 1
Error: Component '_def_init' at (1) with coarray component shall be a nonpointer, nonallocatable scalar

    class(periodic_2nd_order), intent(in) :: this
                                                 1
Error: Variable 'dst' at (1) is INTENT(OUT) and can thus not be an allocatable coarray or have coarray components

    class(periodic_2nd_order), intent(in) :: this
                                                 1
Error: Component '_def_init' at (1) with coarray component shall be a nonpointer, nonallocatable scalar




module periodic_2nd_order_module
  implicit none

  type periodic_2nd_order
    real, allocatable :: global_f(:)[:]
  contains
    procedure :: output
  end type

contains
  subroutine output (this)
    class(periodic_2nd_order), intent(in) :: this
  end subroutine
end module
Comment 1 Tobias Burnus 2011-12-20 08:03:11 UTC
Patch for the _def_init issue:

--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -11492,6 +11492,7 @@ resolve_fl_derived0 (gfc_symbol *sym)

       /* F2008, C444.  */
       if (c->ts.type == BT_DERIVED && c->ts.u.derived->attr.coarray_comp
+         && !sym->attr.vtype
          && (c->attr.codimension || c->attr.pointer || c->attr.dimension
              || c->attr.allocatable))
        {
Comment 2 Tobias Burnus 2012-09-03 06:36:05 UTC
Author: burnus
Date: Mon Sep  3 06:35:59 2012
New Revision: 190869

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=190869
Log:
2012-09-03  Alessandro Fanfarillo  <fanfarillo.gcc@gmail.com>
            Tobias Burnus  <burnus@net-b.de>

        PR fortran/37336
        * gfortran.h (symbol_attribute): Add artificial.
        * module.c (mio_symbol_attribute): Handle attr.artificial
        * class.c (gfc_build_class_symbol): Defer creation of the vtab
        if the DT has finalizers, mark generated symbols as
        attr.artificial.
        (has_finalizer_component, finalize_component,
        finalization_scalarizer, generate_finalization_wrapper):
        New static functions.
        (gfc_find_derived_vtab): Add _final component and call
        generate_finalization_wrapper.
        * dump-parse-tree.c (show_f2k_derived): Use resolved
        proc_tree->n.sym rather than unresolved proc_sym.
        (show_attr): Handle attr.artificial.
        * resolve.c (gfc_resolve_finalizers): Ensure that the vtab
        * exists.
        (resolve_fl_derived): Resolve finalizers before
        generating the vtab.
        (resolve_symbol): Also allow assumed-rank arrays with CONTIGUOUS;
        skip artificial symbols.
        (resolve_fl_derived0): Skip artificial symbols.

2012-09-03  Tobias Burnus  <burnus@net-b.de>

        PR fortran/51632
        * gfortran.dg/coarray_class_1.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/coarray_class_1.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/class.c
    trunk/gcc/fortran/dump-parse-tree.c
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/module.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog
Comment 3 Tobias Burnus 2012-09-03 08:59:19 UTC
Fixed by introducing the "artificial" attribute.

TODO: Check that this patch doesn't worsen the handling of (non)polymorphic coarray components of a polymorphic variable are properly handled for DEALLOCATE/ALLOCATE/intrinsic assignment.
Comment 4 Dominique d'Humieres 2015-10-20 16:32:32 UTC
> Fixed by introducing the "artificial" attribute.
>
> TODO: Check that this patch doesn't worsen the handling of (non)polymorphic
> coarray components of a polymorphic variable are properly handled for
> DEALLOCATE/ALLOCATE/intrinsic assignment.

Any hint about how to do that?
Comment 5 Dominique d'Humieres 2016-04-09 13:10:13 UTC
> > TODO: Check that this patch doesn't worsen the handling of (non)polymorphic
> > coarray components of a polymorphic variable are properly handled for
> > DEALLOCATE/ALLOCATE/intrinsic assignment.
>
> Any hint about how to do that?

No feedback, closing as FIXED. Please open new PR(s) with relevant information for remaining issue(s).