This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [patch, fortran] [5/6 Regression] Line continuation followed by comment character in string fails to compile
- From: Mikael Morin <mikael dot morin at sfr dot fr>
- To: Jerry DeLisle <jvdelisle at charter dot net>, gfortran <fortran at gcc dot gnu dot org>
- Cc: gcc patches <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 16 May 2015 17:17:29 +0200
- Subject: Re: [patch, fortran] [5/6 Regression] Line continuation followed by comment character in string fails to compile
- Authentication-results: sourceware.org; auth=none
- Authentication-results: sfrmc.priv.atos.fr; dkim=none (no signature); dkim-adsp=none (no policy) header dot from=mikael dot morin at sfr dot fr
- References: <55540130 dot 5080206 at charter dot net>
Le 14/05/2015 03:58, Jerry DeLisle a Ãcrit :
> The attached patch reverts a change I made for pr65456 which caused this
> regression and adds a check for quotes farther down in the function. This
> avoids treating a '!' in a string as a comment and wiping the rest of the line.
>
> I found the added code is needed because an interposing quote was falling
> through and being changed into an empty space at around line 1393. (I do not
> recall the history of why that space is being done)
>
> The patch also updates test case continuation_13.f90. I found another compiler I
> use for comparison interprets the continuation differently and is inserting a
> space that is not there. So the format at line 800 is handled differently now
> with gfortran and the line 900 format example is added to test both cases with
> and without a space just before the continuation.
>
> I think now gfortran has this right, but I do not rule out that I am missing
> some obscure rule. This begs a question about the space character substituted
> near line 1393 in scanner.c, but at the moment I do not think it is related.
>
> I have also added a test for the the original problem reported in this PR to
> avoid future repeating of the problem. I will provide a Changelog entry for the
> testsuite changes.
>
> Regression tested on x86-64-linux. OK to trunk? followed to 5.1?
>
> Regards,
>
> Jerry
>
>
> 2015-05-14 Jerry DeLisle <jvdelisle@gcc.gnu.org>
>
> PR fortran/65903
> * io.c (format_lex): Change to NONSTRING when checking for
> possible doubled quote.
> * scanner.c (gfc_next_char_literal): Revert change from 64506,
> add a check for quotes, and return.
>
> Index: gcc/testsuite/gfortran.dg/continuation_13.f90
> ===================================================================
> --- gcc/testsuite/gfortran.dg/continuation_13.f90 (revision 223105)
> +++ gcc/testsuite/gfortran.dg/continuation_13.f90 (working copy)
> @@ -19,6 +19,8 @@ character(25) :: astring
> )
> 800 format('This is actually ok.'& !comment
> ' end' )
> +900 format('This is actually ok.' & !comment
> + ' end' )
> write(astring,100)
> if (astring.ne."This format is OK.") call abort
> write(astring,200)
Hello, is the new format labelled 900 correct?
It seems to me it is equivalent to
900 format('This is actually ok.' ' end')
which is missing a comma, no?
This is a real question, I'm no format guru.
By the way, the existing 800 format is also not right, it shouldn't have
a comment, and it should have a '&' at the beginning of the next line.
Section 3.3.2.4 "Free form statement continuation", last paragraph has:
> If a character context is to be continued, an â&â shall be the last
> nonblank character on the line and shall not be followed by commentary.
> There shall be a later line that is not a comment; an â&â shall be the
> first nonblank character on the next such line and the statement
> continues with the next character following that â&â.
To be honest, I see little value in supporting continuation between the
two consecutive quotes coding one quote inside a string constant, it's
confusing. But if it's supported, the above applies, doesn't it?
Regarding the patch itself, I haven't looked at it in great details yet,
but as it's a revert basically, it shouldn't do a lot of harm.
I see that the fixed form part isn't reverted, is it on purpose?
Mikael