[Bug fortran/68846] Pointer function as LValue doesn't work when the assignment regards a dummy argument.

2018-05-13 Thread pault at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68846

Paul Thomas  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #12 from Paul Thomas  ---
Fixed on 6-branch to trunk.

Thanks for the report and the initial patch.

Paul

PS Dominique and Gerhard, thanks for all your help as well!

PPS It's good to see that somebody is actually using pointer function
assignment.

[Bug fortran/68846] Pointer function as LValue doesn't work when the assignment regards a dummy argument.

2018-05-13 Thread pault at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68846

--- Comment #11 from Paul Thomas  ---
Author: pault
Date: Sun May 13 08:34:50 2018
New Revision: 260208

URL: https://gcc.gnu.org/viewcvs?rev=260208=gcc=rev
Log:
2018-05-13  Paul Thomas  

PR fortran/68846
PR fortran/70864
Backport from trunk
* resolve.c (get_temp_from_expr): The temporary must not have
dummy or intent attributes.

2018-05-13  Paul Thomas  

PR fortran/68846
Backport from trunk
* gfortran.dg/temporary_3.f90 : New test.

PR fortran/70864
Backport from trunk
* gfortran.dg/temporary_2.f90 : New test.


Added:
branches/gcc-6-branch/gcc/testsuite/gfortran.dg/temporary_2.f90
branches/gcc-6-branch/gcc/testsuite/gfortran.dg/temporary_3.f90
Modified:
branches/gcc-6-branch/gcc/fortran/ChangeLog
branches/gcc-6-branch/gcc/fortran/resolve.c
branches/gcc-6-branch/gcc/testsuite/ChangeLog

[Bug fortran/68846] Pointer function as LValue doesn't work when the assignment regards a dummy argument.

2018-05-12 Thread pault at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68846

--- Comment #10 from Paul Thomas  ---
Author: pault
Date: Sat May 12 15:33:24 2018
New Revision: 260195

URL: https://gcc.gnu.org/viewcvs?rev=260195=gcc=rev
Log:
2018-05-12  Paul Thomas  

PR fortran/68846
PR fortran/70864
Backport from trunk
* resolve.c (get_temp_from_expr): The temporary must not have
dummy or intent attributes.

2018-05-12  Paul Thomas  

PR fortran/68846
Backport from trunk
* gfortran.dg/temporary_3.f90 : New test.

PR fortran/70864
Backport from trunk
* gfortran.dg/temporary_2.f90 : New test.


Added:
branches/gcc-7-branch/gcc/testsuite/gfortran.dg/temporary_2.f90
branches/gcc-7-branch/gcc/testsuite/gfortran.dg/temporary_3.f90
Modified:
branches/gcc-7-branch/gcc/fortran/ChangeLog
branches/gcc-7-branch/gcc/fortran/resolve.c
branches/gcc-7-branch/gcc/testsuite/ChangeLog

[Bug fortran/68846] Pointer function as LValue doesn't work when the assignment regards a dummy argument.

2018-05-11 Thread pault at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68846

--- Comment #9 from Paul Thomas  ---
Author: pault
Date: Fri May 11 09:35:55 2018
New Revision: 260160

URL: https://gcc.gnu.org/viewcvs?rev=260160=gcc=rev
Log:
2018-05-11  Paul Thomas  

PR fortran/68846
PR fortran/70864
backport from trunk
* resolve.c (get_temp_from_expr): The temporary must not have
dummy or intent attributes.

2018-05-11  Paul Thomas  

PR fortran/68846
backport from trunk
* gfortran.dg/temporary_3.f90 : New test.

PR fortran/70864
backport from trunk
* gfortran.dg/temporary_2.f90 : New test.


Added:
branches/gcc-8-branch/gcc/testsuite/gfortran.dg/temporary_2.f90
branches/gcc-8-branch/gcc/testsuite/gfortran.dg/temporary_3.f90
Modified:
branches/gcc-8-branch/gcc/fortran/ChangeLog
branches/gcc-8-branch/gcc/fortran/resolve.c
branches/gcc-8-branch/gcc/testsuite/ChangeLog

[Bug fortran/68846] Pointer function as LValue doesn't work when the assignment regards a dummy argument.

2018-05-10 Thread pault at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68846

Paul Thomas  changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |pault at gcc dot gnu.org

--- Comment #8 from Paul Thomas  ---
I will backport as soon as I have time.

Paul

[Bug fortran/68846] Pointer function as LValue doesn't work when the assignment regards a dummy argument.

2018-05-10 Thread pault at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68846

--- Comment #7 from Paul Thomas  ---
Author: pault
Date: Thu May 10 10:48:50 2018
New Revision: 260113

URL: https://gcc.gnu.org/viewcvs?rev=260113=gcc=rev
Log:
2018-05-10  Paul Thomas  

PR fortran/68846
PR fortran/70864
* resolve.c (get_temp_from_expr): The temporary must not have
dummy or intent attributes.

2018-05-10  Paul Thomas  

PR fortran/68846
* gfortran.dg/temporary_3.f90 : New test.

PR fortran/70864
* gfortran.dg/temporary_2.f90 : New test.


Added:
trunk/gcc/testsuite/gfortran.dg/temporary_2.f90
trunk/gcc/testsuite/gfortran.dg/temporary_3.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/resolve.c
trunk/gcc/testsuite/ChangeLog

[Bug fortran/68846] Pointer function as LValue doesn't work when the assignment regards a dummy argument.

2017-02-28 Thread mirco.valentini at polimi dot it
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68846

--- Comment #6 from mirco  ---
Hi all, 
I spent some time today working on this bug. I found a small modification that
allows to build without errors and that seems to work (I did a very preliminary
test).

At the moment I'm working with "gfortran 7.0.1 20170219"

The modification is just:

! ===
file: resolve.c
line: 10690

at the end of the function "resolve_ptr_fcn_assign" add the foolowing lines:
!
(*code)->expr1->symtree->n.sym->attr.dummy = 0;
(*code)->expr1->symtree->n.sym->attr.intent = INTENT_UNKNOWN;
=


The reason is that the temporary pointer used to store the result of the
pointer function should never inherit the "dummy" attribute.

Is there any drawback with this modification? I don't know very well the code
of gfortran and for this reason I don't know the possible implications of this
modification.

Regards,
Mirco

[Bug fortran/68846] Pointer function as LValue doesn't work when the assignment regards a dummy argument.

2016-12-06 Thread gerhard.steinmetz.fort...@t-online.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68846

--- Comment #5 from Gerhard Steinmetz  
---

Related to pr70864  (technically slightly different).
Backtrace identical to that of pr70864 comment 3.

[Bug fortran/68846] Pointer function as LValue doesn't work when the assignment regards a dummy argument.

2016-12-06 Thread gerhard.steinmetz.fort...@t-online.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68846

--- Comment #4 from Gerhard Steinmetz  
---

Further modified and reduced to a skeleton, i.e. :


$ cat z3.f90
module m68846
   type t
   contains
  procedure, nopass :: f => f1
   end type
contains
   function f1() result(p)
  real, pointer :: p
   end
   subroutine s3(z, value)
  type(t) :: z
  real, intent(in) :: value
  z%f() = value
   end
end module


$ cat z4.f90
module m68846
   type t
   contains
  procedure, nopass :: f => f1
   end type
contains
   function f1() result(p)
  real, pointer :: p
   end
   subroutine s3(z, value)
  type(t) :: z
  real, intent(inout) :: value
  z%f() = value   !!
   end
end module


$ gfortran-7-20161204 -c z3.f90
z3.f90:13:19:

   z%f() = value
   1
Error: Dummy argument '_F.DA0' with INTENT(IN) in pointer association context
(pointer assignment) at (1)


$ gfortran-7-20161204 -c z4.f90
z4.f90:7:0:

function f1() result(p)

internal compiler error: in gfc_get_symbol_decl, at fortran/trans-decl.c:1477
0x75a352 gfc_get_symbol_decl(gfc_symbol*)
../../gcc/fortran/trans-decl.c:1477
0x75e5b7 generate_local_decl
../../gcc/fortran/trans-decl.c:5327
0x71825b do_traverse_symtree
../../gcc/fortran/symbol.c:3994
0x75f412 generate_local_vars
../../gcc/fortran/trans-decl.c:5527
0x75f412 gfc_generate_function_code(gfc_namespace*)
../../gcc/fortran/trans-decl.c:6206
0x7331f9 gfc_generate_module_code(gfc_namespace*)
../../gcc/fortran/trans.c:2164
0x6e72fd translate_all_program_units
../../gcc/fortran/parse.c:6025
0x6e72fd gfc_parse_file()
../../gcc/fortran/parse.c:6238
0x72b182 gfc_be_parse_file
../../gcc/fortran/f95-lang.c:202

[Bug fortran/68846] Pointer function as LValue doesn't work when the assignment regards a dummy argument.

2016-12-06 Thread gerhard.steinmetz.fort...@t-online.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68846

--- Comment #3 from Gerhard Steinmetz  
---

Both variants reduced and simplified a bit :


$ cat z1.f90
module m68846
  type grid_t
real, pointer :: p(:) => null()
  end type
  type subgrid_t
class(grid_t), pointer :: grd => null()
  contains
procedure, pass :: jmp => lvalue_jmp
  end type
contains
  function lvalue_jmp(hobj, i) result(p)
class(subgrid_t), intent(inout) :: hobj
integer, intent(in) :: i
real, pointer :: p
p => hobj%grd%p(i)
  end
  subroutine fillgeom_03(subgrid, value)
type(subgrid_t), intent(inout) :: subgrid
real, intent(in) :: value
subgrid%jmp(1) = value
  end
end module


$ cat z2.f90
module m68846
  type grid_t
real, pointer :: p(:) => null()
  end type
  type subgrid_t
class(grid_t), pointer :: grd => null()
  contains
procedure, pass :: jmp => lvalue_jmp
  end type
contains
  function lvalue_jmp(hobj, i) result(p)
class(subgrid_t), intent(inout) :: hobj
integer, intent(in) :: i
real, pointer :: p
p => hobj%grd%p(i)
  end
  subroutine fillgeom_03(subgrid, value)
type(subgrid_t), intent(inout) :: subgrid
real, intent(inout) :: value   !!
subgrid%jmp(1) = value
  end
end module


$ gfortran-7-20161204 -c z1.f90
z1.f90:20:26:

 subgrid%jmp(1) = value
  1
Error: Dummy argument '_F.DA0' with INTENT(IN) in pointer association context
(pointer assignment) at (1)


$ gfortran-7-20161204 -c z2.f90
z2.f90:22:0:

 end module

internal compiler error: in gfc_get_symbol_decl, at fortran/trans-decl.c:1477
0x75a352 gfc_get_symbol_decl(gfc_symbol*)
../../gcc/fortran/trans-decl.c:1477
0x75e5b7 generate_local_decl
../../gcc/fortran/trans-decl.c:5327
0x71825b do_traverse_symtree
../../gcc/fortran/symbol.c:3994
0x75f412 generate_local_vars
../../gcc/fortran/trans-decl.c:5527
0x75f412 gfc_generate_function_code(gfc_namespace*)
../../gcc/fortran/trans-decl.c:6206
0x7331f9 gfc_generate_module_code(gfc_namespace*)
../../gcc/fortran/trans.c:2164
0x6e72fd translate_all_program_units
../../gcc/fortran/parse.c:6025
0x6e72fd gfc_parse_file()
../../gcc/fortran/parse.c:6238
0x72b182 gfc_be_parse_file
../../gcc/fortran/f95-lang.c:202

[Bug fortran/68846] Pointer function as LValue doesn't work when the assignment regards a dummy argument.

2016-12-06 Thread gerhard.steinmetz.fort...@t-online.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68846

Gerhard Steinmetz  changed:

   What|Removed |Added

 CC||gerhard.steinmetz.fortran@t
   ||-online.de

--- Comment #2 from Gerhard Steinmetz  
---
Update, new backtrace :


$ gfortran-7-20161204 -c pr68846_in.f90
pr68846_in.f90:61:32:

 subgrid%jmp(i,j) = value
1
Error: Dummy argument '_F.DA0' with INTENT(IN) in pointer association context
(pointer assignment) at (1)


$ gfortran-7-20161204 -c pr68846_inout.f90
pr68846_inout.f90:53:0:

   SUBROUTINE fillgeom_03( subgrid, value  )

internal compiler error: in gfc_get_symbol_decl, at fortran/trans-decl.c:1477
0x75a352 gfc_get_symbol_decl(gfc_symbol*)
../../gcc/fortran/trans-decl.c:1477
0x75e5b7 generate_local_decl
../../gcc/fortran/trans-decl.c:5327
0x71825b do_traverse_symtree
../../gcc/fortran/symbol.c:3994
0x75f412 generate_local_vars
../../gcc/fortran/trans-decl.c:5527
0x75f412 gfc_generate_function_code(gfc_namespace*)
../../gcc/fortran/trans-decl.c:6206
0x7331f9 gfc_generate_module_code(gfc_namespace*)
../../gcc/fortran/trans.c:2164
0x6e72fd translate_all_program_units
../../gcc/fortran/parse.c:6025
0x6e72fd gfc_parse_file()
../../gcc/fortran/parse.c:6238
0x72b182 gfc_be_parse_file
../../gcc/fortran/f95-lang.c:202

[Bug fortran/68846] Pointer function as LValue doesn't work when the assignment regards a dummy argument.

2015-12-11 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68846

Dominique d'Humieres  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2015-12-11
 CC||pault at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #1 from Dominique d'Humieres  ---
Confirmed on trunk (6.0) for revisions newer than r228222 (pr63921).