Re: [Patch] Fortran: Accept -std=f2023, update line-length for Fortran 2023

2024-01-02 Thread Harald Anlauf

Am 02.01.24 um 20:37 schrieb Steve Kargl:

On Tue, Jan 02, 2024 at 08:31:15PM +0100, Harald Anlauf wrote:


we might want to update changes.html to reflect this.  How about:

diff --git a/htdocs/gcc-14/changes.html b/htdocs/gcc-14/changes.html
index 403feb06..9b16f5e3 100644
--- a/htdocs/gcc-14/changes.html
+++ b/htdocs/gcc-14/changes.html
@@ -284,6 +284,11 @@ a work-in-progress.

  Fortran
  
+  The compiler now accepts the -std=f2023 option, which
+has been added in preparation of support of Fortran 2023.  This option
+increases the line-length limit for source in free-form to 1, and
+statements may have up to 1 million characters.
+  
 With the -save-temps option, preprocessed files
  with the .fii extension will be generated from
  free-form source files such as .F90 and



LGTM.



Thanks, this is now pushed.




Re: [Patch] Fortran: Accept -std=f2023, update line-length for Fortran 2023

2024-01-02 Thread Steve Kargl
On Tue, Jan 02, 2024 at 08:31:15PM +0100, Harald Anlauf wrote:
> 
> we might want to update changes.html to reflect this.  How about:
> 
> diff --git a/htdocs/gcc-14/changes.html b/htdocs/gcc-14/changes.html
> index 403feb06..9b16f5e3 100644
> --- a/htdocs/gcc-14/changes.html
> +++ b/htdocs/gcc-14/changes.html
> @@ -284,6 +284,11 @@ a work-in-progress.
> 
>  Fortran
>  
> +  The compiler now accepts the -std=f2023 option, which
> +has been added in preparation of support of Fortran 2023.  This option
> +increases the line-length limit for source in free-form to 1, and
> +statements may have up to 1 million characters.
> +  
> With the -save-temps option, preprocessed files
>  with the .fii extension will be generated from
>  free-form source files such as .F90 and
> 

LGTM.

-- 
Steve


Re: [Patch] Fortran: Accept -std=f2023, update line-length for Fortran 2023

2024-01-02 Thread Harald Anlauf

Dear all,

we might want to update changes.html to reflect this.  How about:

diff --git a/htdocs/gcc-14/changes.html b/htdocs/gcc-14/changes.html
index 403feb06..9b16f5e3 100644
--- a/htdocs/gcc-14/changes.html
+++ b/htdocs/gcc-14/changes.html
@@ -284,6 +284,11 @@ a work-in-progress.

 Fortran
 
+  The compiler now accepts the -std=f2023 option, which
+has been added in preparation of support of Fortran 2023.  This option
+increases the line-length limit for source in free-form to 1, and
+statements may have up to 1 million characters.
+  
With the -save-temps option, preprocessed files
 with the .fii extension will be generated from
 free-form source files such as .F90 and


Cheers,
Harald


Am 17.11.23 um 12:38 schrieb Tobias Burnus:

Hi Harald, hi all,

On 16.11.23 20:30, Harald Anlauf wrote:

On 11/16/23 14:01, Tobias Burnus wrote:

This adds -std=f2023, which is mostly a prep patch for future changes.

...

(B) In "6.3.2.6 Free form statements":
Fortran 2018: "A statement shall not have more than 255 continuation
lines."
Fortran 2023: "A statement shall not have more than one million
characters."


this is really a funny change: we're not really prepared to handle
this.


I can confirm this. I tried to get it working in scanner.cc but due to
the re-parsing it is quite difficult to get it right; the main problem
is that we keep reparsing code ("gfc_current_locus = old_loc"), such
that a simple count will be wrong.

→ Now tracked at https://gcc.gnu.org/PR112586



According to the standard one can have 99 lines with only
"&" and then an ";", but then only 100 lines with 1 characters.


I believe a single '&' is not valid, you either need '&&' or something
else + '&'; thus, you can have only half a million lines + 1.

In the code, I still use 1,000,000 but now with a comment.


There is a similar wording for fixed-form which you overlooked:

Ups - fixed.

If you think that we need testcases for fixed-form, add them,
or forget them.  I don't bother.

I added one.


- there are existing testcases continuation_5.f, continuation_6.f,
  thus I suggest to rename your new continuation_{5,6}.f90 to
  continuation_17.f90+ .


Done. We are rather inconsistent whether we enumerate .f{,90}
together or separately; as the suffix is shown, either works.



- I don't understand your new testcase line_length_14.f90 .
  This is supposed to test -std=gnu, but then -std=gnu is not a
  standard but a moving target, which is why you had to adjust
  existing testcases.
  So what does it buy us beyond line_length_1{2,3}.f90 ?


Well, it ensures that the warning is not only shown for -std=f2023 but
also for -std=f2028 and (current -std=gnu). In general, I think it is
useful to check the lower and the upper bound.

I have now removed it - as it is unlikely that we would regress on such
changes.


PPS: I did not bother adding .f23 as file extension; I believe that also
.f18 is unsupported.

I never use extensions other than .f90 for portable code.


Likewise  - especially as '.f95' starts out as Fortran code that
complies to -std=f95 but slowly Fortran 2003 or later code creeps in. I
think that's fine but then one can also directly use .f90. (Most code
does so.)

Unless there are follow up comments, I will commit it later today.

Thanks for the comments!

Tobias

PS: I fixed the wording issue in the subject line of the email and
header. I first wrote 'support' but that sounded a bit as if F2023 is
supported. Hence, I wrote 'Accept' and did not remove 'support'.
-
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 
80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: 
Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; 
Registergericht München, HRB 106955





Re: [Patch] Fortran: Accept -std=f2023, update line-length for Fortran 2023

2023-11-17 Thread Harald Anlauf

Hi Tobias,

On 11/17/23 12:38, Tobias Burnus wrote:

Hi Harald, hi all,

On 16.11.23 20:30, Harald Anlauf wrote:

According to the standard one can have 99 lines with only
"&" and then an ";", but then only 100 lines with 1 characters.


I believe a single '&' is not valid, you either need '&&' or something
else + '&'; thus, you can have only half a million lines + 1.


after looking at the F2023 standard again I wonder why
they did such a disservice to compiler developers...

You are right: a single '&' is not valid.

6.3.2.4 also has:

"When used for continuation, the “&” is not part of the statement"

And 6.3.2.5 (also 6.3.3.4): "The “;” is not part of the statement".

So a million "&"-continued lines is possible in free form.

For fixed form, 6.3.3.1 has: "If a source line contains only characters
of default kind, it shall contain exactly 72 characters; otherwise, its
maximum number of characters is processor dependent."

I wonder what I should make out of this...


In the code, I still use 1,000,000 but now with a comment.


Yeah, for the time being this is the most reasonable solution.
Let's claim that the 10^6 line limit is the new GNU standard ;-)

Cheers,
Harald




Re: [Patch] Fortran: Accept -std=f2023, update line-length for Fortran 2023

2023-11-17 Thread Mikael Morin

Le 17/11/2023 à 12:38, Tobias Burnus a écrit :


Unless there are follow up comments, I will commit it later today.


I skimmed quickly through the patch, and noticed one typo to fix:

> diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi
> index 10387e39501..5f87b330a22 100644
> --- a/gcc/fortran/invoke.texi
> +++ b/gcc/fortran/invoke.texi
> @@ -958,8 +959,8 @@ The following example will trigger the warning.
>  @item -Wampersand
>  Warn about missing ampersand in continued character constants. The
>  warning is given with @option{-Wampersand}, @option{-pedantic},
> -@option{-std=f95}, @option{-std=f2003}, @option{-std=f2008} and
> -@option{-std=f2018}. Note: With no ampersand given in a continued
> +@option{-std=f95}, @option{-std=f2003}, @option{-std=f2008}, 
@option{-std=f2018}

> +and @option{-std=f203}. Note: With no ampersand given in a continued
>  character constant, GNU Fortran assumes continuation at the first
>  non-comment, non-whitespace character after the ampersand that
>  initiated the continuation.

s/f203/f2023/