public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/45290]  New: [F08] pointer initialization
@ 2010-08-15 19:46 janus at gcc dot gnu dot org
  2010-08-16  7:35 ` [Bug fortran/45290] " domob at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: janus at gcc dot gnu dot org @ 2010-08-15 19:46 UTC (permalink / raw)
  To: gcc-bugs

John Reid, The new features of Fortran 2008, chapter 5.5:

A pointer may be initially associated with a target:

type (entry), target :: bottom
type (entry), pointer :: top => bottom

*****

Currently gfortran responds with:

type (entry), pointer :: top => bottom
                               1
Error: Pointer initialization requires a NULL() at (1)

*****

A look at the current draft of F08 seems to indicate that this is allowed for
any kind of pointer: Data pointers and data pointer components as well as
procedure pointers and procedure pointer components. See:

R442 component-initialization
R443 initial-data-target
C460

R505 initialization
C511

R1216 proc-pointer-init
R1217 initial-proc-target

Note: For procedure-pointer components I was not able to find any specific
reference to non-NULL default initialization. However, chapter 4.5.4.6
("Default initialization for components") explicitly mentions the possibility
of having an initial-proc-target for a PPC.


-- 
           Summary: [F08] pointer initialization
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: janus at gcc dot gnu dot org
OtherBugsDependingO 39627
             nThis:


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45290


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/45290] [F08] pointer initialization
  2010-08-15 19:46 [Bug fortran/45290] New: [F08] pointer initialization janus at gcc dot gnu dot org
@ 2010-08-16  7:35 ` domob at gcc dot gnu dot org
  2010-08-16  9:17 ` burnus at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: domob at gcc dot gnu dot org @ 2010-08-16  7:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from domob at gcc dot gnu dot org  2010-08-16 07:34 -------
Confirmed.


-- 

domob at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |domob at gcc dot gnu dot org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2010-08-16 07:34:39
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45290


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/45290] [F08] pointer initialization
  2010-08-15 19:46 [Bug fortran/45290] New: [F08] pointer initialization janus at gcc dot gnu dot org
  2010-08-16  7:35 ` [Bug fortran/45290] " domob at gcc dot gnu dot org
@ 2010-08-16  9:17 ` burnus at gcc dot gnu dot org
  2010-08-16  9:37 ` janus at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-08-16  9:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from burnus at gcc dot gnu dot org  2010-08-16 09:17 -------
(In reply to comment #0)
> Note: For procedure-pointer components I was not able to find any specific
> reference to non-NULL default initialization.

It is allowed per:

R440 proc-component-def-stmt   is   PROCEDURE ( [ proc-interface ] ) ,
                              proc-component-attr-spec-list :: proc-decl-list

As "proc-decl-list" refers to (click on it in the PDF):

R1214 proc-decl   is   procedure-entity-name [ => proc-pointer-init ]

with

R1216 proc-pointer-init    is  null-init
                           or  initial-proc-target
R1217 initial-proc-target  is  procedure-name


> John Reid, The new features of Fortran 2008

Besides John's article, you also find a list of new features in the
"Introduction" (page xv) of the Fortran 2008 standard.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45290


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/45290] [F08] pointer initialization
  2010-08-15 19:46 [Bug fortran/45290] New: [F08] pointer initialization janus at gcc dot gnu dot org
  2010-08-16  7:35 ` [Bug fortran/45290] " domob at gcc dot gnu dot org
  2010-08-16  9:17 ` burnus at gcc dot gnu dot org
@ 2010-08-16  9:37 ` janus at gcc dot gnu dot org
  2010-08-18 22:32 ` janus at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu dot org @ 2010-08-16  9:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from janus at gcc dot gnu dot org  2010-08-16 09:37 -------
(In reply to comment #2)
> (In reply to comment #0)
> > Note: For procedure-pointer components I was not able to find any specific
> > reference to non-NULL default initialization.
> 
> It is allowed per:
> 
> R440 proc-component-def-stmt   is   PROCEDURE ( [ proc-interface ] ) ,
>                               proc-component-attr-spec-list :: proc-decl-list
> 
> As "proc-decl-list" refers to (click on it in the PDF):
> 
> R1214 proc-decl   is   procedure-entity-name [ => proc-pointer-init ]

Right. I missed that. (I guess I was expecting an explicit reference to
'proc-pointer-init' around R440.)


Also: Mine. (I'm working on a patch.)


-- 

janus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |janus at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2010-08-16 07:34:39         |2010-08-16 09:37:09
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45290


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/45290] [F08] pointer initialization
  2010-08-15 19:46 [Bug fortran/45290] New: [F08] pointer initialization janus at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2010-08-16  9:37 ` janus at gcc dot gnu dot org
@ 2010-08-18 22:32 ` janus at gcc dot gnu dot org
  2010-08-18 22:37 ` janus at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu dot org @ 2010-08-18 22:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from janus at gcc dot gnu dot org  2010-08-18 22:32 -------
Subject: Bug 45290

Author: janus
Date: Wed Aug 18 22:32:22 2010
New Revision: 163356

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=163356
Log:
2010-08-19  Janus Weil  <janus@gcc.gnu.org>

        PR fortran/45290
        * gfortran.h (gfc_add_save): Modified prototype.
        * decl.c (add_init_expr_to_sym): Defer checking of proc pointer init.
        (match_pointer_init): New function to match F08 pointer initialization.
        (variable_decl,match_procedure_decl,match_ppc_decl): Use
        'match_pointer_init'.
        (match_attr_spec): Module variables are implicitly SAVE.
        (gfc_match_save): Modified call to 'gfc_add_save'.
        * expr.c (gfc_check_assign_symbol): Extra checks for pointer
        initialization.
        * primary.c (gfc_variable_attr): Handle SAVE attribute.
        * resolve.c (resolve_structure_cons): Add new argument and do pointer
        initialization checks.
        (gfc_resolve_expr): Modified call to 'resolve_structure_cons'.
        (resolve_values): Call 'resolve_structure_cons' directly with init arg.
        (resolve_fl_variable): Handle SAVE_IMPLICIT.
        * symbol.c (gfc_add_save,gfc_copy_attr,save_symbol): Handle
        SAVE_IMPLICIT.
        * trans-decl.c (gfc_create_module_variable): Module variables with
        TARGET can already exist.
        * trans-expr.c (gfc_conv_variable): Check for 'current_function_decl'.
        (gfc_conv_initializer): Implement non-NULL pointer
        initialization.


2010-08-19  Janus Weil  <janus@gcc.gnu.org>

        PR fortran/45290
        * gfortran.dg/proc_ptr_comp_3.f90: Modified.
        * gfortran.dg/pointer_init_2.f90: New.
        * gfortran.dg/pointer_init_3.f90: New.
        * gfortran.dg/pointer_init_4.f90: New.

Added:
    trunk/gcc/testsuite/gfortran.dg/pointer_init_2.f90
    trunk/gcc/testsuite/gfortran.dg/pointer_init_3.f90
    trunk/gcc/testsuite/gfortran.dg/pointer_init_4.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/decl.c
    trunk/gcc/fortran/expr.c
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/primary.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/fortran/symbol.c
    trunk/gcc/fortran/trans-decl.c
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/proc_ptr_comp_3.f90


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45290


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/45290] [F08] pointer initialization
  2010-08-15 19:46 [Bug fortran/45290] New: [F08] pointer initialization janus at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2010-08-18 22:32 ` janus at gcc dot gnu dot org
@ 2010-08-18 22:37 ` janus at gcc dot gnu dot org
  2010-08-19 11:11 ` janus at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu dot org @ 2010-08-18 22:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from janus at gcc dot gnu dot org  2010-08-18 22:37 -------
r163356 implements pointer initialization.

Leftover To-Do items:

(1) ICE on 

module m
 implicit none
 integer, target, save  :: t1
 integer, pointer :: p1 => t
 integer, pointer :: p2 => p1    ! ICE
end module m


(2) Making global variables in a program SAVE_IMPLICIT.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45290


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/45290] [F08] pointer initialization
  2010-08-15 19:46 [Bug fortran/45290] New: [F08] pointer initialization janus at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2010-08-18 22:37 ` janus at gcc dot gnu dot org
@ 2010-08-19 11:11 ` janus at gcc dot gnu dot org
  2010-08-21 14:51 ` janus at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu dot org @ 2010-08-19 11:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from janus at gcc dot gnu dot org  2010-08-19 11:11 -------
There are also still problems with procedure pointers:

module m
implicit none
procedure(f1), pointer :: pp => f1
contains
  integer function f1()
    f1 = 42
  end function
end module

use m
implicit none
if (pp()/=42) call abort()
end


This one fails with:

f951: internal compiler error: in build_function_decl, at
fortran/trans-decl.c:1611


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45290


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/45290] [F08] pointer initialization
  2010-08-15 19:46 [Bug fortran/45290] New: [F08] pointer initialization janus at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2010-08-19 11:11 ` janus at gcc dot gnu dot org
@ 2010-08-21 14:51 ` janus at gcc dot gnu dot org
  2010-08-21 16:21 ` janus at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu dot org @ 2010-08-21 14:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from janus at gcc dot gnu dot org  2010-08-21 14:51 -------
Subject: Bug 45290

Author: janus
Date: Sat Aug 21 14:50:57 2010
New Revision: 163445

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=163445
Log:
2010-08-21  Janus Weil  <janus@gcc.gnu.org>

        PR fortran/45271
        PR fortran/45290
        * class.c (add_proc_comp): Add static initializer for PPCs.
        (add_procs_to_declared_vtab): Modified comment.
        * module.c (mio_component): Add argument 'vtype'. Don't read/write the
        initializer if the component is part of a vtype.
        (mio_component_list): Add argument 'vtype', pass it on to
        'mio_component'.
        (mio_symbol): Modified call to 'mio_component_list'.
        * trans.h (gfc_conv_initializer): Modified prototype.
        (gfc_trans_assign_vtab_procs): Removed.
        * trans-common.c (create_common): Modified call to
        'gfc_conv_initializer'.
        * trans-decl.c (gfc_get_symbol_decl,get_proc_pointer_decl,
        gfc_emit_parameter_debug_info): Modified call to
        'gfc_conv_initializer'.
        (build_function_decl): Remove assertion.
        * trans-expr.c (gfc_conv_derived_to_class,gfc_trans_class_assign):
        Removed call to 'gfc_trans_assign_vtab_procs'.
        (gfc_conv_initializer): Add argument 'procptr'.
        (gfc_conv_structure): Modified call to 'gfc_conv_initializer'.
        (gfc_trans_assign_vtab_procs): Removed.
        * trans-stmt.c (gfc_trans_allocate): Removed call to
        'gfc_trans_assign_vtab_procs'.


2010-08-21  Janus Weil  <janus@gcc.gnu.org>

        PR fortran/44863
        PR fortran/45271
        PR fortran/45290
        * gfortran.dg/dynamic_dispatch_10.f03: New (PR 44863 comment #1).
        * gfortran.dg/pointer_init_5.f90: New (PR 45290 comment #6).
        * gfortran.dg/typebound_call_18.f03: New (PR 45271 comment #3).

Added:
    trunk/gcc/testsuite/gfortran.dg/dynamic_dispatch_10.f03
    trunk/gcc/testsuite/gfortran.dg/pointer_init_5.f90
    trunk/gcc/testsuite/gfortran.dg/typebound_call_18.f03
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/class.c
    trunk/gcc/fortran/module.c
    trunk/gcc/fortran/trans-common.c
    trunk/gcc/fortran/trans-decl.c
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/fortran/trans-stmt.c
    trunk/gcc/fortran/trans.h
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45290


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/45290] [F08] pointer initialization
  2010-08-15 19:46 [Bug fortran/45290] New: [F08] pointer initialization janus at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2010-08-21 14:51 ` janus at gcc dot gnu dot org
@ 2010-08-21 16:21 ` janus at gcc dot gnu dot org
  2010-09-21 12:38 ` burnus at gcc dot gnu dot org
  2010-09-21 13:52 ` burnus at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: janus at gcc dot gnu dot org @ 2010-08-21 16:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from janus at gcc dot gnu dot org  2010-08-21 16:21 -------
Comment #6 is fixed by r163445, but comment #5 is still open.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45290


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/45290] [F08] pointer initialization
  2010-08-15 19:46 [Bug fortran/45290] New: [F08] pointer initialization janus at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2010-08-21 16:21 ` janus at gcc dot gnu dot org
@ 2010-09-21 12:38 ` burnus at gcc dot gnu dot org
  2010-09-21 13:52 ` burnus at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-09-21 12:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from burnus at gcc dot gnu dot org  2010-09-21 12:37 -------
Another issue besides comment 5 is the following program (from PR 45740), which
gives an ICE.

Actually, I am not quite sure the example is valid as "p2"'s target is not
known at compile time.



module m
  procedure(), pointer :: p2
end module m

  use m
  procedure(), pointer :: ptr3 => p2
  call ptr3()  ! ICE, related to PR 45290
! internal compiler error: in record_reference, at cgraphbuild.c:60
  end


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45290


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug fortran/45290] [F08] pointer initialization
  2010-08-15 19:46 [Bug fortran/45290] New: [F08] pointer initialization janus at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2010-09-21 12:38 ` burnus at gcc dot gnu dot org
@ 2010-09-21 13:52 ` burnus at gcc dot gnu dot org
  9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-09-21 13:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from burnus at gcc dot gnu dot org  2010-09-21 13:52 -------
(In reply to comment #9)
>   procedure(), pointer :: ptr3 => p2

I now believe that this is invalid (all quotes are F2008):

R505 initialization is [...]  or  => initial-data-target
R443 initial-data-target  is  designator

C461 (R443) The designator shall designate a nonallocatable variable that has
the TARGET and SAVE attributes and does not have a vector subscript. Every
subscript, section subscript, substring starting point, and substring ending
point in designator shall be a constant expression.


Well, in the example (cf. also the ICE in comment 5) "p2" is a POINTER and a
pointer cannot have the TARGET attribute (cf. C556).

Thus, the "initial-data-target" can neither be a pointer nor a proc-pointer.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45290


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2010-09-21 13:52 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-15 19:46 [Bug fortran/45290] New: [F08] pointer initialization janus at gcc dot gnu dot org
2010-08-16  7:35 ` [Bug fortran/45290] " domob at gcc dot gnu dot org
2010-08-16  9:17 ` burnus at gcc dot gnu dot org
2010-08-16  9:37 ` janus at gcc dot gnu dot org
2010-08-18 22:32 ` janus at gcc dot gnu dot org
2010-08-18 22:37 ` janus at gcc dot gnu dot org
2010-08-19 11:11 ` janus at gcc dot gnu dot org
2010-08-21 14:51 ` janus at gcc dot gnu dot org
2010-08-21 16:21 ` janus at gcc dot gnu dot org
2010-09-21 12:38 ` burnus at gcc dot gnu dot org
2010-09-21 13:52 ` burnus at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).