This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/84389] Defined output: unexpected compiler error with the use of ":" edit descriptor


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84389

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #1 from kargl at gcc dot gnu.org ---
(In reply to Vipul Parekh from comment #0)
> Consider the following:
> 
> --- begin console output ---
> C:\Temp>type p.f90
> module m
> 
>    type :: t
>       private

If you add 

        integer i 

to work around the issue you reported in different bug report,
and ...

>    contains
>       private
>       procedure, pass(this) :: write_t
>       generic, public :: write(formatted) => write_t
>    end type
> 
> contains
> 
>    subroutine write_t(this, lun, iotype, vlist, istat, imsg)
> 
>       ! argument definitions
>       class(t), intent(in)            :: this
>       integer, intent(in)             :: lun
>       character(len=*), intent(in)    :: iotype
>       integer, intent(in)             :: vlist(:)
>       integer, intent(out)            :: istat
>       character(len=*), intent(inout) :: imsg
> 
>       write(lun, fmt=*, iostat=istat, iomsg=imsg) "Hello World!"
> 
>       return
> 
>    end subroutine write_t
> 
> end module
> 
> program p
> 
>    use m, only : t
> 
>    type(t) :: foo(2)
> 
>    print "(*(dt:,','))", foo

provide a valid format-item, then gfortran gives
the expected output.

gfcx -o z b.f90 && ./z
Hello World!, Hello World!

The EBNF in F2018 is

R1301 format-stmt           is FORMAT format-specification

R1302 format-specification  is ( [ format-items ] )
                            or ( [ format-items, ] unlimited-format-item )

R1305 unlimited-format-item is * ( format-items )

R1303 format-items          is format-item [ [ , ] format-item ] ...

R1304 format-item           is [ r ] data-edit-desc
                            or control-edit-desc

R1307 data-edit-desc        is I w [ . m ]
                            ...
                            or DT [ char-literal-constant ][ ( v-list ) ]

R724 char-literal-constant  is [ kind-param _ ] ' [ rep-char ] ... '
                            or [ kind-param _ ] " [ rep-char ] ... "

R1312 v                     is signed-int-literal-constant

R1313 control-edit-desc     is position-edit-desc
                            or :

You have DT:.  The colon is neither a char-literal-constant nor v-list.
If you want the colon to be a control-edit-desc, then you need to 
include a format-item for it.

The format string you want is "(*(dt,:','))".

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]