* Backslash character at the end of a comment
@ 2017-09-25 15:41 Vladimír Fuka
2017-09-27 0:24 ` Klint Gore
0 siblings, 1 reply; 6+ messages in thread
From: Vladimír Fuka @ 2017-09-25 15:41 UTC (permalink / raw)
To: fortran
Hello,
I noticed strange error after adding a comment. Unexpected elses and end if.
I realized the comment had \ at the end. I added a space after it and I got
strings.f90:102:76: warning: backslash and newline separated by space
[enabled by default]
! " finishes the string and is not counted to it if not escaped by \
^
strings.f90:119.10:
and again the same error, unexpected elses and end if.
Does this reject valid source files or not? What purpose does it
serve? Does it mean a comment is continued on the next line by using a
backslash?
Regards,
Vladimir
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Backslash character at the end of a comment
@ 2017-09-25 16:38 Dominique d'Humières
2017-09-25 16:40 ` Vladimír Fuka
0 siblings, 1 reply; 6+ messages in thread
From: Dominique d'Humières @ 2017-09-25 16:38 UTC (permalink / raw)
To: vladimir.fuka; +Cc: gfortran
Vladimir,
> I noticed strange error after adding a comment. Unexpected elses and end if.
>
> I realized the comment had \ at the end. I added a space after it and I got
> …
Could you please post the code? AFAIR, backslash is not part of the Fortran character set and can only appear in strings (no patience to look at the standard). Gfortran has an option -fbackslash allowing backslash to be interpreted as an escape character (again AFAIU). You may want to have a look at gfortran.dg/backslash*.
Cheers,
Dominique
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Backslash character at the end of a comment
2017-09-25 16:38 Dominique d'Humières
@ 2017-09-25 16:40 ` Vladimír Fuka
2017-09-25 16:49 ` Dominique d'Humières
0 siblings, 1 reply; 6+ messages in thread
From: Vladimír Fuka @ 2017-09-25 16:40 UTC (permalink / raw)
To: Dominique d'Humières; +Cc: gfortran
I suppose the code can be just
!\
end
Vlad
Dne 25. 9. 2017 6:38 odpoledne napsal uživatel "Dominique d'Humières" <
dominiq@lps.ens.fr>:
> Vladimir,
>
> > I noticed strange error after adding a comment. Unexpected elses and end
> if.
> >
> > I realized the comment had \ at the end. I added a space after it and I
> got
> > …
>
> Could you please post the code? AFAIR, backslash is not part of the
> Fortran character set and can only appear in strings (no patience to look
> at the standard). Gfortran has an option -fbackslash allowing backslash to
> be interpreted as an escape character (again AFAIU). You may want to have a
> look at gfortran.dg/backslash*.
>
> Cheers,
>
> Dominique
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Backslash character at the end of a comment
2017-09-25 16:40 ` Vladimír Fuka
@ 2017-09-25 16:49 ` Dominique d'Humières
2017-09-26 9:20 ` Vladimír Fuka
0 siblings, 1 reply; 6+ messages in thread
From: Dominique d'Humières @ 2017-09-25 16:49 UTC (permalink / raw)
To: Vladimír Fuka; +Cc: gfortran
> Le 25 sept. 2017 à 18:40, Vladimír Fuka <vladimir.fuka@gmail.com> a écrit :
>
> I suppose the code can be just
>
> !\
> end
>
> Vlad
% cat > backslash_1.f90
!\
end
% gfc backslash_1.f90
% ./a.out
%
for all the revisions I have tested with/without -fbackslash.
Dominique
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Backslash character at the end of a comment
2017-09-25 16:49 ` Dominique d'Humières
@ 2017-09-26 9:20 ` Vladimír Fuka
0 siblings, 0 replies; 6+ messages in thread
From: Vladimír Fuka @ 2017-09-26 9:20 UTC (permalink / raw)
To: Dominique d'Humières; +Cc: gfortran
So it was the -cpp which was in effect, although there were no macros
in the source files. The code is
!\
if (i>1) then
end if
end
The error
> gfortran -cpp backslash.f90
backslash.f90:3.3:
end if
1
Error: Expecting END PROGRAM statement at (1)
I knew the backslash is used to continue a macro on the next line,
but I didn't know it has en effect also outside of macros.
Regards,
Vlad
2017-09-25 18:49 GMT+02:00 Dominique d'Humières <dominiq@lps.ens.fr>:
>
>> Le 25 sept. 2017 à 18:40, Vladimír Fuka <vladimir.fuka@gmail.com> a écrit :
>>
>> I suppose the code can be just
>>
>> !\
>> end
>>
>> Vlad
>
> % cat > backslash_1.f90
> !\
> end
> % gfc backslash_1.f90
> % ./a.out
> %
>
> for all the revisions I have tested with/without -fbackslash.
>
> Dominique
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-09-27 0:24 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-25 15:41 Backslash character at the end of a comment Vladimír Fuka
2017-09-27 0:24 ` Klint Gore
2017-09-25 16:38 Dominique d'Humières
2017-09-25 16:40 ` Vladimír Fuka
2017-09-25 16:49 ` Dominique d'Humières
2017-09-26 9:20 ` Vladimír Fuka
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).