[Bug fortran/84504] [F08] procedure pointer variables cannot be initialized with functions returning pointers

2019-03-09 Thread janus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84504

janus at gcc dot gnu.org changed:

   What|Removed |Added

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

--- Comment #10 from janus at gcc dot gnu.org ---
Fixed on 9-trunk with r269529. Closing.

[Bug fortran/84504] [F08] procedure pointer variables cannot be initialized with functions returning pointers

2019-03-09 Thread janus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84504

--- Comment #9 from janus at gcc dot gnu.org ---
Author: janus
Date: Sat Mar  9 18:25:39 2019
New Revision: 269529

URL: https://gcc.gnu.org/viewcvs?rev=269529=gcc=rev
Log:
fix PR 84504

2019-03-09  Janus Weil  

PR fortran/84504
* expr.c (gfc_check_assign_symbol): Deal with procedure pointers to
pointer-valued functions.

2019-03-09  Janus Weil  

PR fortran/84504
* gfortran.dg/pointer_init_10.f90: New test case.

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

[Bug fortran/84504] [F08] procedure pointer variables cannot be initialized with functions returning pointers

2019-03-09 Thread nmsriram at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84504

--- Comment #8 from nmsriram at gmail dot com ---
Thank you!
I had given up on this.
:-)
Sriram

On Sat, Mar 9, 2019 at 7:48 PM janus at gcc dot gnu.org <
gcc-bugzi...@gcc.gnu.org> wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84504
>
> --- Comment #7 from janus at gcc dot gnu.org ---
> The following patch fixes the problem and shows no regressions on
> x86_64-linux-gnu:
>
> diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
> index 51552a79cde..4e95f243661 100644
> --- a/gcc/fortran/expr.c
> +++ b/gcc/fortran/expr.c
> @@ -4321,7 +4321,7 @@ gfc_check_assign_symbol (gfc_symbol *sym,
> gfc_component
> *comp, gfc_expr *rvalue)
>if (!r)
>  return r;
>
> -  if (pointer && rvalue->expr_type != EXPR_NULL)
> +  if (pointer && rvalue->expr_type != EXPR_NULL && !proc_pointer)
>  {
>/* F08:C461. Additional checks for pointer initialization.  */
>symbol_attribute attr;
>
> --
> You are receiving this mail because:
> You reported the bug.

[Bug fortran/84504] [F08] procedure pointer variables cannot be initialized with functions returning pointers

2019-03-09 Thread janus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84504

--- Comment #7 from janus at gcc dot gnu.org ---
The following patch fixes the problem and shows no regressions on
x86_64-linux-gnu:

diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index 51552a79cde..4e95f243661 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -4321,7 +4321,7 @@ gfc_check_assign_symbol (gfc_symbol *sym, gfc_component
*comp, gfc_expr *rvalue)
   if (!r)
 return r;

-  if (pointer && rvalue->expr_type != EXPR_NULL)
+  if (pointer && rvalue->expr_type != EXPR_NULL && !proc_pointer)
 {
   /* F08:C461. Additional checks for pointer initialization.  */
   symbol_attribute attr;

[Bug fortran/84504] [F08] procedure pointer variables cannot be initialized with functions returning pointers

2019-03-09 Thread janus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84504

janus at gcc dot gnu.org changed:

   What|Removed |Added

Summary|[F03] procedure pointer |[F08] procedure pointer
   |variables cannot be |variables cannot be
   |initialized with functions  |initialized with functions
   |returning pointers  |returning pointers

--- Comment #6 from janus at gcc dot gnu.org ---
Note that non-NULL pointer initialization is a Fortran 2008 feature (not
permitted in the 2003 standard).