(j3.2006) Multiple & on free-form continuation?

Daniel C Chen cdchen
Thu Aug 28 11:06:26 EDT 2014


Just to add to this.

> Ian Harvey sent me the following amusing source:
>
>   PRINT "(A)", 'There is something ' & &
>     // 'wrong with this statement.'
> END
>

XL Fortran compiler also complains about the first '&' on the first line.
We mark it as an error. As a result, we flag errors for the 2nd line
(Syntax error) as well.

>
> Also interesting:
>
>   PRINT "(A)", "Is there something & &
> & wrong with this statement?"
>

XL Fortran compiles this case successfully.

Daniel

XL Fortran Development - IBM Toronto Software Lab
Phone: 905-413-3056
Tie: 969-3056
Email: cdchen at ca.ibm.com
http://www.ibm.com/software/awdtools/fortran/xlfortran



From:	Bill Long <longb at cray.com>
To:	fortran standards email list for J3
            <j3 at mailman.j3-fortran.org>,
Date:	08/27/2014 15:28
Subject:	Re: (j3.2006) Multiple & on free-form continuation?
Sent by:	j3-bounces at mailman.j3-fortran.org




On Aug 27, 2014, at 1:57 PM, Lionel, Steve <steve.lionel at intel.com> wrote:

> Ian Harvey sent me the following amusing source:
>
>   PRINT "(A)", 'There is something ' & &
>     // 'wrong with this statement.'
> END
>
> and noted that Intel Fortran failed to diagnose this as an error. I can
read the words in the standard as not disallowing this. 3.3.2.4 says:
>
> If a noncharacter context is to be continued, an "&" shall be the last
nonblank character on the line, or the last nonblank character before an
"!".
>
> An & is the last nonblank character, just not the only &. I don?t see any
words that prohibit multiple ?&? characters at the end of a continued line.
>
> gfortran doesn?t like this one.


The Cray and PGI compilers also reject this.  The Cray parsing: The final &
on the first line is the continuation sentinel. What comes before that,
including the first &,  is part of the io-list of the print statement.
But ?There is something ? & ?wrong with this statement.? is not valid
syntax for a character expression.  Message: Unexpected syntax while
parsing the PRINT statement.

PGI took the opposite approach and assumed the first & was the continuation
sentinel, and objected to non-comment text on the line after the &.
Message:  Non-comment character after a '&? .

I?m biased toward the Cray message, but either way this is not conforming
code.


>
> Also interesting:
>
>   PRINT "(A)", "Is there something & &
> & wrong with this statement?"
>
> Intel Fortran accepts this and treats the first & as an ordinary
character ? gfortran does the same, and I think I can justify this from the
text in paragraph 4.

This one is fine.  The character constant itself is continued across the
line break and has the value ?Is there something &  wrong with this
statement??.   Single io-list item with valid syntax.

>
> Is the first case interp fodder?

I don?t think so.

Cheers,
Bill

>
> Steve Lionel
> Intel Developer Support
> Merrimack, NH
>
> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3

Bill Long
longb at cray.com
Fortran Technical Suport  &                                  voice:
651-605-9024
Bioinformatics Software Development                     fax:  651-605-9142
Cray Inc./ Cray Plaza, Suite 210/ 380 Jackson St./ St. Paul, MN 55101


_______________________________________________
J3 mailing list
J3 at mailman.j3-fortran.org
http://mailman.j3-fortran.org/mailman/listinfo/j3

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.j3-fortran.org/pipermail/j3/attachments/20140828/0de2ee77/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
Url : http://mailman.j3-fortran.org/pipermail/j3/attachments/20140828/0de2ee77/attachment.gif 



More information about the J3 mailing list