aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2023-11-17 13:34:55 +0100
committerTobias Burnus <tobias@codesourcery.com>2023-11-17 13:34:55 +0100
commitb9eba3baf54b4fc25c3006768bb945058622658b (patch)
tree0c48ceb04bf97204b1701352be80059cc4c1f831 /gcc/fortran
parent68221c54a9752dbf131c231413edfd21046f8dad (diff)
downloadgcc-b9eba3baf54b4fc25c3006768bb945058622658b.zip
gcc-b9eba3baf54b4fc25c3006768bb945058622658b.tar.gz
gcc-b9eba3baf54b4fc25c3006768bb945058622658b.tar.bz2
Fortran: Accept -std=f2023, update line-length for Fortran 2023
This patch accepts -std=f2023, uses it by default and bumps for the free-source form the line length to 10,000 and the statement length alias number of continuation lines to unlimited. gcc/fortran/ChangeLog: * gfortran.texi (_gfortran_set_options): Document GFC_STD_F2023. * invoke.texi (std,pedantic,Wampersand,Wtabs): Add -std=2023. * lang.opt (std=f2023): Add. * libgfortran.h (GFC_STD_F2023, GFC_STD_OPT_F23): Add. * options.cc (set_default_std_flags): Add GFC_STD_F2023. (gfc_init_options): Set max_continue_free to 1,000,000. (gfc_post_options): Set flag_free_line_length if unset. (gfc_handle_option): Add OPT_std_f2023, set max_continue_free = 255 for -std=f2003, f2008 and f2018. gcc/testsuite/ChangeLog: * gfortran.dg/goacc/warn_truncated.f90: Add -std=f2018 option. * gfortran.dg/gomp/warn_truncated.f90: Likewise. * gfortran.dg/line_length_10.f90: Likewise. * gfortran.dg/line_length_11.f90: Likewise. * gfortran.dg/line_length_2.f90: Likewise. * gfortran.dg/line_length_5.f90: Likewise. * gfortran.dg/line_length_6.f90: Likewise. * gfortran.dg/line_length_7.f90: Likewise. * gfortran.dg/line_length_8.f90: Likewise. * gfortran.dg/line_length_9.f90: Likewise. * gfortran.dg/continuation_17.f90: New test. * gfortran.dg/continuation_18.f90: New test. * gfortran.dg/continuation_19.f: New test. * gfortran.dg/line_length_12.f90: New test. * gfortran.dg/line_length_13.f90: New test.
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/gfortran.texi11
-rw-r--r--gcc/fortran/invoke.texi21
-rw-r--r--gcc/fortran/lang.opt4
-rw-r--r--gcc/fortran/libgfortran.h4
-rw-r--r--gcc/fortran/options.cc28
5 files changed, 49 insertions, 19 deletions
diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi
index e7ffc29..41857cc 100644
--- a/gcc/fortran/gfortran.texi
+++ b/gcc/fortran/gfortran.texi
@@ -3477,11 +3477,12 @@ standard. Possible values are (bitwise or-ed) @code{GFC_STD_F77} (1),
@code{GFC_STD_F95} (8), @code{GFC_STD_F2003} (16), @code{GFC_STD_GNU}
(32), @code{GFC_STD_LEGACY} (64), @code{GFC_STD_F2008} (128),
@code{GFC_STD_F2008_OBS} (256), @code{GFC_STD_F2008_TS} (512),
-@code{GFC_STD_F2018} (1024), @code{GFC_STD_F2018_OBS} (2048), and
-@code{GFC_STD=F2018_DEL} (4096). Default: @code{GFC_STD_F95_OBS |
-GFC_STD_F95_DEL | GFC_STD_F95 | GFC_STD_F2003 | GFC_STD_F2008 |
-GFC_STD_F2008_TS | GFC_STD_F2008_OBS | GFC_STD_F77 | GFC_STD_F2018 |
-GFC_STD_F2018_OBS | GFC_STD_F2018_DEL | GFC_STD_GNU | GFC_STD_LEGACY}.
+@code{GFC_STD_F2018} (1024), @code{GFC_STD_F2018_OBS} (2048),
+@code{GFC_STD=F2018_DEL} (4096), and @code{GFC_STD=F2023} (8192).
+Default: @code{GFC_STD_F95_OBS | GFC_STD_F95_DEL | GFC_STD_F95 |
+GFC_STD_F2003 | GFC_STD_F2008 | GFC_STD_F2008_TS | GFC_STD_F2008_OBS
+| GFC_STD_F77 | GFC_STD_F2018 | GFC_STD_F2018_OBS | GFC_STD_F2018_DEL
+| GFC_STD_F2023 | GFC_STD_GNU | GFC_STD_LEGACY}.
@item @var{option}[1] @tab Standard-warning flag; prints a warning to
standard error. Default: @code{GFC_STD_F95_DEL | GFC_STD_LEGACY}.
@item @var{option}[2] @tab If non zero, enable pedantic checking.
diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi
index 10387e3..2f1d1f2 100644
--- a/gcc/fortran/invoke.texi
+++ b/gcc/fortran/invoke.texi
@@ -542,17 +542,17 @@ intermediate representation of the translated Fortran code, produced by
@opindex @code{std=}@var{std} option
@item -std=@var{std}
Specify the standard to which the program is expected to conform,
-which may be one of @samp{f95}, @samp{f2003}, @samp{f2008},
-@samp{f2018}, @samp{gnu}, or @samp{legacy}. The default value for
+which may be one of @samp{f95}, @samp{f2003}, @samp{f2008}, @samp{f2018},
+@samp{f2023}, @samp{gnu}, or @samp{legacy}. The default value for
@var{std} is @samp{gnu}, which specifies a superset of the latest
Fortran standard that includes all of the extensions supported by GNU
Fortran, although warnings will be given for obsolete extensions not
recommended for use in new code. The @samp{legacy} value is
equivalent but without the warnings for obsolete extensions, and may
-be useful for old non-standard programs. The @samp{f95},
-@samp{f2003}, @samp{f2008}, and @samp{f2018} values specify strict
-conformance to the Fortran 95, Fortran 2003, Fortran 2008 and Fortran
-2018 standards, respectively; errors are given for all extensions
+be useful for old non-standard programs. The @samp{f95}, @samp{f2003},
+@samp{f2008}, @samp{f2018}, and @samp{f2023} values specify strict
+conformance to the Fortran 95, Fortran 2003, Fortran 2008, Fortran 2018
+and Fortran 2023 standards, respectively; errors are given for all extensions
beyond the relevant language standard, and warnings are given for the
Fortran 77 features that are permitted but obsolescent in later
standards. The deprecated option @samp{-std=f2008ts} acts as an alias for
@@ -910,7 +910,8 @@ nonstandard practices, but not all.
However, improvements to GNU Fortran in this area are welcome.
This should be used in conjunction with @option{-std=f95},
-@option{-std=f2003}, @option{-std=f2008} or @option{-std=f2018}.
+@option{-std=f2003}, @option{-std=f2008}, @option{-std=f2018}
+or @option{-std=f2023}.
@opindex @code{pedantic-errors}
@item -pedantic-errors
@@ -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=f2023}. 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.
@@ -1108,7 +1109,7 @@ of the Fortran Character Set. For continuation lines, a tab followed
by a digit between 1 and 9 is supported. @option{-Wtabs} will cause a
warning to be issued if a tab is encountered. Note, @option{-Wtabs} is
active for @option{-pedantic}, @option{-std=f95}, @option{-std=f2003},
-@option{-std=f2008}, @option{-std=f2018} and
+@option{-std=f2008}, @option{-std=f2018}, @option{-std=f2023} and
@option{-Wall}.
@opindex @code{Wundefined-do-loop}
diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
index 7236351..08c7539 100644
--- a/gcc/fortran/lang.opt
+++ b/gcc/fortran/lang.opt
@@ -883,6 +883,10 @@ std=f2018
Fortran
Conform to the ISO Fortran 2018 standard.
+std=f2023
+Fortran
+Conform to the ISO Fortran 2023 standard.
+
std=f95
Fortran
Conform to the ISO Fortran 95 standard.
diff --git a/gcc/fortran/libgfortran.h b/gcc/fortran/libgfortran.h
index cb84b59..bdddb31 100644
--- a/gcc/fortran/libgfortran.h
+++ b/gcc/fortran/libgfortran.h
@@ -19,9 +19,10 @@ along with GCC; see the file COPYING3. If not see
/* Flags to specify which standard/extension contains a feature.
- Note that no features were obsoleted nor deleted in F2003.
+ Note that no features were obsoleted nor deleted in F2003 nor in F2023.
Please remember to keep those definitions in sync with
gfortran.texi. */
+#define GFC_STD_F2023 (1<<12) /* New in F2023. */
#define GFC_STD_F2018_DEL (1<<11) /* Deleted in F2018. */
#define GFC_STD_F2018_OBS (1<<10) /* Obsolescent in F2018. */
#define GFC_STD_F2018 (1<<9) /* New in F2018. */
@@ -45,6 +46,7 @@ along with GCC; see the file COPYING3. If not see
#define GFC_STD_OPT_F08 (GFC_STD_OPT_F03 | GFC_STD_F2008)
#define GFC_STD_OPT_F18 ((GFC_STD_OPT_F08 | GFC_STD_F2018) \
& (~GFC_STD_F2018_DEL))
+#define GFC_STD_OPT_F23 (GFC_STD_OPT_F18 | GFC_STD_F2023)
/* Bitmasks for the various FPE that can be enabled. These need to be straight integers
e.g., 8 instead of (1<<3), because they will be included in Fortran source. */
diff --git a/gcc/fortran/options.cc b/gcc/fortran/options.cc
index cfb1957..b788521 100644
--- a/gcc/fortran/options.cc
+++ b/gcc/fortran/options.cc
@@ -57,7 +57,7 @@ set_default_std_flags (void)
gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
| GFC_STD_F2003 | GFC_STD_F2008 | GFC_STD_F95 | GFC_STD_F77
| GFC_STD_F2008_OBS | GFC_STD_GNU | GFC_STD_LEGACY
- | GFC_STD_F2018 | GFC_STD_F2018_DEL | GFC_STD_F2018_OBS;
+ | GFC_STD_F2018 | GFC_STD_F2018_DEL | GFC_STD_F2018_OBS | GFC_STD_F2023;
gfc_option.warn_std = GFC_STD_F2018_DEL | GFC_STD_F95_DEL | GFC_STD_LEGACY;
}
@@ -143,8 +143,11 @@ gfc_init_options (unsigned int decoded_options_count,
gfc_source_file = NULL;
gfc_option.module_dir = NULL;
gfc_option.source_form = FORM_UNKNOWN;
- gfc_option.max_continue_fixed = 255;
- gfc_option.max_continue_free = 255;
+ /* The following is not quite right as Fortran since 2023 has: "A statement
+ shall not have more than one million characters." This can already be
+ reached by 'just' 100 lines with 10,000 characters each. */
+ gfc_option.max_continue_fixed = 1000000;
+ gfc_option.max_continue_free = 1000000;
gfc_option.max_identifier_length = GFC_MAX_SYMBOL_LEN;
gfc_option.max_errors = 25;
@@ -266,6 +269,10 @@ gfc_post_options (const char **pfilename)
cpp_warn_missing_include_dirs, 1);
gfc_check_include_dirs (verbose_missing_dir_warn);
+ SET_OPTION_IF_UNSET (&global_options, &global_options_set,
+ flag_free_line_length,
+ (gfc_option.allow_std & GFC_STD_F2023) ? 10000 : 132);
+
/* Finalize DEC flags. */
post_dec_flags (flag_dec);
@@ -769,6 +776,8 @@ gfc_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
case OPT_std_f2003:
gfc_option.allow_std = GFC_STD_OPT_F03;
gfc_option.warn_std = GFC_STD_F95_OBS;
+ gfc_option.max_continue_fixed = 255;
+ gfc_option.max_continue_free = 255;
gfc_option.max_identifier_length = 63;
warn_ampersand = 1;
warn_tabs = 1;
@@ -777,6 +786,8 @@ gfc_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
case OPT_std_f2008:
gfc_option.allow_std = GFC_STD_OPT_F08;
gfc_option.warn_std = GFC_STD_F95_OBS | GFC_STD_F2008_OBS;
+ gfc_option.max_continue_free = 255;
+ gfc_option.max_continue_fixed = 255;
gfc_option.max_identifier_length = 63;
warn_ampersand = 1;
warn_tabs = 1;
@@ -787,6 +798,17 @@ gfc_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
gfc_option.allow_std = GFC_STD_OPT_F18;
gfc_option.warn_std = GFC_STD_F95_OBS | GFC_STD_F2008_OBS
| GFC_STD_F2018_OBS;
+ gfc_option.max_continue_free = 255;
+ gfc_option.max_continue_fixed = 255;
+ gfc_option.max_identifier_length = 63;
+ warn_ampersand = 1;
+ warn_tabs = 1;
+ break;
+
+ case OPT_std_f2023:
+ gfc_option.allow_std = GFC_STD_OPT_F23;
+ gfc_option.warn_std = GFC_STD_F95_OBS | GFC_STD_F2008_OBS
+ | GFC_STD_F2018_OBS;
gfc_option.max_identifier_length = 63;
warn_ampersand = 1;
warn_tabs = 1;