Support -std=f2018

Message ID 1513504945-20886-1-git-send-email-blomqvist.janne@gmail.com
State New
Headers show
Series
  • Support -std=f2018
Related show

Commit Message

Janne Blomqvist Dec. 17, 2017, 10:02 a.m.
The Fortran committee has decided to rename the upcoming Fortran 2015
standard to Fortran 2018.  This is not a reflection of a three year
delay in the process, but rather they are following other standards in
adopting the year of publication for the name. For more details see
N2144.

This patch renames GFC_STD_F2015 to GFC_STD_F2018, and makes it a
separate flag rather than an alias for GFC_STD_GNU. Also, it adds a
-std=f2018 argument, and documents it.

Regtested on x86_64-pc-linux-gnu, Ok for trunk?

gcc/fortran/ChangeLog:

2017-12-17  Janne Blomqvist  <jb@gcc.gnu.org>

	* decl.c (gfc_match_implicit_none): Use GFC_STD_F2018 instead of
	GFC_STD_F2015.
	* error.c (gfc_notify_std): Add GFC_STD_F2018{_DEL,_OBS} to
	switch.
	* gfortran.texi: Document -std=f2018.
	* interface.c (compare_parameter): Fix comment.
	* invoke.texi: Document -std=f2018.
	* lang.opt: Add -std=f2018 argumnet.
	* libgfortran.h (GFC_STD_F2015): Rename to GFC_STD_F0218, use
	separate flag bit.
	(GFC_STD_F2018_DEL): New macro.
	(GFC_STD_F2018_OBS): Likewise.
	* match.c (gfc_match_stopcode): Use GFC_STD_F2018.
	* options.c (set_default_std_flags): Add F2018 flags to defaults.
	(gfc_handle_option): Set options for -std=f2018.

gcc/testsuite/ChangeLog:

2017-12-17  Janne Blomqvist  <jb@gcc.gnu.org>

	* gfortran.dg/error_stop_3.f90: Update -std= option, fix comments.
	* gfortran.dg/error_stop_4.f90: Update error message.
	* gfortran.dg/implicit_14.f90: Likewise.
	* gfortran.dg/spellcheck-procedure_2.f90: Don't warn for F2018
	features.
---
 gcc/fortran/decl.c                                 |   2 +-
 gcc/fortran/error.c                                |   9 ++
 gcc/fortran/gfortran.texi                          | 108 +++++++++++++--------
 gcc/fortran/interface.c                            |   2 +-
 gcc/fortran/invoke.texi                            |  62 ++++++------
 gcc/fortran/lang.opt                               |   6 +-
 gcc/fortran/libgfortran.h                          |   5 +-
 gcc/fortran/match.c                                |   2 +-
 gcc/fortran/options.c                              |  14 ++-
 gcc/testsuite/gfortran.dg/error_stop_3.f90         |   5 +-
 gcc/testsuite/gfortran.dg/error_stop_4.f90         |   5 +-
 gcc/testsuite/gfortran.dg/implicit_14.f90          |   4 +-
 .../gfortran.dg/spellcheck-procedure_2.f90         |   2 +-
 13 files changed, 140 insertions(+), 86 deletions(-)

-- 
2.7.4

Comments

Robin Curtis Dec. 17, 2017, 10:10 a.m. | #1
Apologies for lobbing this request to all you wonderful folk who maintain and develop GFORTRAN. 

Given that you are making noises about Fortran 2018 - and the language is still alive, kicking and thriving -  can you recommend and/or point me at a public domain GUI that works well with GFORTRAN? 

As a Fortran end User I marvel at your ongoing efforts !!

Regards / thanks.  Happy Christmas and Best Wishes for (Fortran) 2018. 

Robin Curtis

> On 17 Dec 2017, at 10:02, Janne Blomqvist <blomqvist.janne@gmail.com> wrote:

> 

> The Fortran committee has decided to rename the upcoming Fortran 2015

> standard to Fortran 2018.  This is not a reflection of a three year

> delay in the process, but rather they are following other standards in

> adopting the year of publication for the name. For more details see

> N2144.

> 

> This patch renames GFC_STD_F2015 to GFC_STD_F2018, and makes it a

> separate flag rather than an alias for GFC_STD_GNU. Also, it adds a

> -std=f2018 argument, and documents it.

> 

> Regtested on x86_64-pc-linux-gnu, Ok for trunk?

> 

> gcc/fortran/ChangeLog:

> 

> 2017-12-17  Janne Blomqvist  <jb@gcc.gnu.org>

> 

> 	* decl.c (gfc_match_implicit_none): Use GFC_STD_F2018 instead of

> 	GFC_STD_F2015.

> 	* error.c (gfc_notify_std): Add GFC_STD_F2018{_DEL,_OBS} to

> 	switch.

> 	* gfortran.texi: Document -std=f2018.

> 	* interface.c (compare_parameter): Fix comment.

> 	* invoke.texi: Document -std=f2018.

> 	* lang.opt: Add -std=f2018 argumnet.

> 	* libgfortran.h (GFC_STD_F2015): Rename to GFC_STD_F0218, use

> 	separate flag bit.

> 	(GFC_STD_F2018_DEL): New macro.

> 	(GFC_STD_F2018_OBS): Likewise.

> 	* match.c (gfc_match_stopcode): Use GFC_STD_F2018.

> 	* options.c (set_default_std_flags): Add F2018 flags to defaults.

> 	(gfc_handle_option): Set options for -std=f2018.

> 

> gcc/testsuite/ChangeLog:

> 

> 2017-12-17  Janne Blomqvist  <jb@gcc.gnu.org>

> 

> 	* gfortran.dg/error_stop_3.f90: Update -std= option, fix comments.

> 	* gfortran.dg/error_stop_4.f90: Update error message.

> 	* gfortran.dg/implicit_14.f90: Likewise.

> 	* gfortran.dg/spellcheck-procedure_2.f90: Don't warn for F2018

> 	features.

> ---

> gcc/fortran/decl.c                                 |   2 +-

> gcc/fortran/error.c                                |   9 ++

> gcc/fortran/gfortran.texi                          | 108 +++++++++++++--------

> gcc/fortran/interface.c                            |   2 +-

> gcc/fortran/invoke.texi                            |  62 ++++++------

> gcc/fortran/lang.opt                               |   6 +-

> gcc/fortran/libgfortran.h                          |   5 +-

> gcc/fortran/match.c                                |   2 +-

> gcc/fortran/options.c                              |  14 ++-

> gcc/testsuite/gfortran.dg/error_stop_3.f90         |   5 +-

> gcc/testsuite/gfortran.dg/error_stop_4.f90         |   5 +-

> gcc/testsuite/gfortran.dg/implicit_14.f90          |   4 +-

> .../gfortran.dg/spellcheck-procedure_2.f90         |   2 +-

> 13 files changed, 140 insertions(+), 86 deletions(-)

> 

> diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c

> index d46083c..53a87b6 100644

> --- a/gcc/fortran/decl.c

> +++ b/gcc/fortran/decl.c

> @@ -4114,7 +4114,7 @@ gfc_match_implicit_none (void)

>   if (c == '(')

>     {

>       (void) gfc_next_ascii_char ();

> -      if (!gfc_notify_std (GFC_STD_F2015, "IMPORT NONE with spec list at %C"))

> +      if (!gfc_notify_std (GFC_STD_F2018, "IMPORT NONE with spec list at %C"))

> 	return MATCH_ERROR;

> 

>       gfc_gobble_whitespace ();

> diff --git a/gcc/fortran/error.c b/gcc/fortran/error.c

> index 2cece49..f11dadc 100644

> --- a/gcc/fortran/error.c

> +++ b/gcc/fortran/error.c

> @@ -864,6 +864,15 @@ gfc_notify_std (int std, const char *gmsgid, ...)

> 

>   switch (std)

>   {

> +    case GFC_STD_F2018_DEL:

> +      msg = _("Fortran 2018 deleted feature:");

> +      break;

> +    case GFC_STD_F2018_OBS:

> +      msg = _("Fortran 2018 obsolescent feature:");

> +      break;

> +    case GFC_STD_F2018:

> +      msg = _("Fortran 2018:");

> +      break;

>     case GFC_STD_F2008_TS:

>       msg = "TS 29113/TS 18508:";

>       break;

> diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi

> index 36c7b94..aabf268 100644

> --- a/gcc/fortran/gfortran.texi

> +++ b/gcc/fortran/gfortran.texi

> @@ -180,7 +180,7 @@ Part I: Invoking GNU Fortran

> * Runtime::              Influencing runtime behavior with environment variables.

> 

> Part II: Language Reference

> -* Fortran 2003 and 2008 status::  Fortran 2003 and 2008 features supported by GNU Fortran.

> +* Fortran standards status::      Fortran 2003, 2008 and 2018 features supported by GNU Fortran.

> * Compiler Characteristics::      User-visible implementation details.

> * Extensions::                    Language extensions implemented by GNU Fortran.

> * Mixed-Language Programming::    Interoperability with C

> @@ -243,16 +243,15 @@ or alternative to, the Unix @command{f95} command;

> @section About GNU Fortran

> 

> The GNU Fortran compiler supports the Fortran 77, 90 and 95 standards

> -completely, parts of the Fortran 2003 and Fortran 2008 standards, and

> +completely, parts of the Fortran 2003, 2008 and 2018 standards, and

> several vendor extensions.  The development goal is to provide the

> following features:

> 

> @itemize @bullet

> @item

> -Read a user's program,

> -stored in a file and containing instructions written

> -in Fortran 77, Fortran 90, Fortran 95, Fortran 2003 or Fortran 2008.

> -This file contains @dfn{source code}.

> +Read a user's program, stored in a file and containing instructions

> +written in Fortran 77, Fortran 90, Fortran 95, Fortran 2003, Fortran

> +2008 or Fortran 2018.  This file contains @dfn{source code}.

> 

> @item

> Translate the user's program into instructions a computer

> @@ -504,10 +503,11 @@ G77 can be compiled with GNU Fortran, although there are a few minor known

> regressions.

> 

> The primary work remaining to be done on GNU Fortran falls into three

> -categories: bug fixing (primarily regarding the treatment of invalid code

> -and providing useful error messages), improving the compiler optimizations

> -and the performance of compiled code, and extending the compiler to support

> -future standards---in particular, Fortran 2003 and Fortran 2008.

> +categories: bug fixing (primarily regarding the treatment of invalid

> +code and providing useful error messages), improving the compiler

> +optimizations and the performance of compiled code, and extending the

> +compiler to support future standards---in particular, Fortran 2003,

> +Fortran 2008 and Fortran 2018.

> 

> 

> @c ---------------------------------------------------------------------

> @@ -527,13 +527,14 @@ ISO/IEC 1539:1997 (Fortran 95).  As such, it can also compile essentially all

> standard-compliant Fortran 90 and Fortran 77 programs.   It also supports

> the ISO/IEC TR-15581 enhancements to allocatable arrays.

> 

> -GNU Fortran also have a partial support for ISO/IEC 1539-1:2004 (Fortran

> -2003), ISO/IEC 1539-1:2010 (Fortran 2008), the Technical Specification

> -@code{Further Interoperability of Fortran with C} (ISO/IEC TS 29113:2012).

> -Full support of those standards and future Fortran standards is planned.

> -The current status of the support is can be found in the

> -@ref{Fortran 2003 status}, @ref{Fortran 2008 status}, @ref{TS 29113 status}

> -and @ref{TS 18508 status} sections of the documentation.

> +GNU Fortran also have a partial support for ISO/IEC 1539-1:2004

> +(Fortran 2003), ISO/IEC 1539-1:2010 (Fortran 2008), the Technical

> +Specification @code{Further Interoperability of Fortran with C}

> +(ISO/IEC TS 29113:2012).  Full support of those standards and future

> +Fortran standards is planned.  The current status of the support is

> +can be found in the @ref{Fortran 2003 status}, @ref{Fortran 2008

> +status}, @ref{TS 29113 status}, @ref{TS 18508 status} and @ref{Fortran

> +2018 status} sections of the documentation.

> 

> Additionally, the GNU Fortran compilers supports the OpenMP specification

> (version 4.0 and most of the features of the 4.5 version,

> @@ -783,17 +784,18 @@ compile option was used.

> @end tex

> 

> @c ---------------------------------------------------------------------

> -@c Fortran 2003 and 2008 Status

> +@c Fortran standards status

> @c ---------------------------------------------------------------------

> 

> -@node Fortran 2003 and 2008 status

> -@chapter Fortran 2003 and 2008 Status

> +@node Fortran standards status

> +@chapter Fortran standards status

> 

> @menu

> * Fortran 2003 status::

> * Fortran 2008 status::

> * TS 29113 status::

> * TS 18508 status::

> +* Fortran 2018 status::

> @end menu

> 

> @node Fortran 2003 status

> @@ -1145,6 +1147,27 @@ polymorphic components.

> @end itemize

> 

> 

> +@node Fortran 2018 status

> +@section Status of Fortran 2018 support

> +

> +So far very little work has been done to support Fortran 2018.

> +

> +@itemize

> +@item ERROR STOP in a PURE procedure

> +An @code{ERROR STOP} statement is permitted in a @code{PURE}

> +procedure.

> +

> +@item IMPLICIT NONE with a spec-list

> +Support the @code{IMPLICIT NONE} statement with an

> +@code{implicit-none-spec-list}.

> +

> +@item Behavior of INQUIRE with the RECL= specifier

> +

> +The behavior of the @code{INQUIRE} statement with the @code{RECL=}

> +specifier now conforms to Fortran 2018.

> +

> +@end itemize

> +

> @c ---------------------------------------------------------------------

> @c Compiler Characteristics

> @c ---------------------------------------------------------------------

> @@ -1482,18 +1505,19 @@ extensions.

> @section Extensions implemented in GNU Fortran

> @cindex extensions, implemented

> 

> -GNU Fortran implements a number of extensions over standard

> -Fortran.  This chapter contains information on their syntax and

> -meaning.  There are currently two categories of GNU Fortran

> -extensions, those that provide functionality beyond that provided

> -by any standard, and those that are supported by GNU Fortran

> -purely for backward compatibility with legacy compilers.  By default,

> -@option{-std=gnu} allows the compiler to accept both types of

> -extensions, but to warn about the use of the latter.  Specifying

> -either @option{-std=f95}, @option{-std=f2003} or @option{-std=f2008}

> -disables both types of extensions, and @option{-std=legacy} allows both

> -without warning.  The special compile flag @option{-fdec} enables additional

> -compatibility extensions along with those enabled by @option{-std=legacy}.

> +GNU Fortran implements a number of extensions over standard Fortran.

> +This chapter contains information on their syntax and meaning.  There

> +are currently two categories of GNU Fortran extensions, those that

> +provide functionality beyond that provided by any standard, and those

> +that are supported by GNU Fortran purely for backward compatibility

> +with legacy compilers.  By default, @option{-std=gnu} allows the

> +compiler to accept both types of extensions, but to warn about the use

> +of the latter.  Specifying either @option{-std=f95},

> +@option{-std=f2003}, @option{-std=f2008}, or @option{-std=f2018}

> +disables both types of extensions, and @option{-std=legacy} allows

> +both without warning.  The special compile flag @option{-fdec} enables

> +additional compatibility extensions along with those enabled by

> +@option{-std=legacy}.

> 

> @menu

> * Old-style kind specifications::

> @@ -3602,15 +3626,17 @@ used.

> @item @emph{option flag list}:

> @multitable @columnfractions .15 .70

> @item @var{option}[0] @tab Allowed standard; can give run-time errors

> -if e.g. an input-output edit descriptor is invalid in a given standard.

> -Possible values are (bitwise or-ed) @code{GFC_STD_F77} (1),

> -@code{GFC_STD_F95_OBS} (2), @code{GFC_STD_F95_DEL} (4), @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) and GFC_STD_F2008_TS (512). 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_GNU | GFC_STD_LEGACY}.

> +if e.g. an input-output edit descriptor is invalid in a given

> +standard.  Possible values are (bitwise or-ed) @code{GFC_STD_F77} (1),

> +@code{GFC_STD_F95_OBS} (2), @code{GFC_STD_F95_DEL} (4),

> +@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}.

> @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/interface.c b/gcc/fortran/interface.c

> index 1b7ebf5..cd02214 100644

> --- a/gcc/fortran/interface.c

> +++ b/gcc/fortran/interface.c

> @@ -2355,7 +2355,7 @@ compare_parameter (gfc_symbol *formal, gfc_expr *actual,

>   if (formal->attr.codimension)

>     {

>       /* F2008, 12.5.2.8 + Corrig 2 (IR F08/0048).  */

> -      /* F2015, 12.5.2.8.  */

> +      /* F2018, 12.5.2.8.  */

>       if (formal->attr.dimension

> 	  && (formal->attr.contiguous || formal->as->type != AS_ASSUMED_SHAPE)

> 	  && actual_attr.dimension

> diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi

> index f3a8b34..7b6f161 100644

> --- a/gcc/fortran/invoke.texi

> +++ b/gcc/fortran/invoke.texi

> @@ -467,22 +467,24 @@ representation of the translated Fortran code, produced by

> 

> @item -std=@var{std}

> @opindex @code{std=}@var{std} option

> -Specify the standard to which the program is expected to conform, which

> -may be one of @samp{f95}, @samp{f2003}, @samp{f2008}, @samp{gnu}, or

> -@samp{legacy}.  The default value for @var{std} is @samp{gnu}, which

> -specifies a superset of the Fortran 95 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} and @samp{f2008} values specify strict

> -conformance to the Fortran 95, Fortran 2003 and Fortran 2008 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. @samp{-std=f2008ts}

> -allows the Fortran 2008 standard including the additions of the 

> -Technical Specification (TS) 29113 on Further Interoperability of Fortran

> -with C and TS 18508 on Additional Parallel Features in Fortran.

> +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

> +@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

> +beyond the relevant language standard, and warnings are given for the

> +Fortran 77 features that are permitted but obsolescent in later

> +standards. @samp{-std=f2008ts} allows the Fortran 2008 standard

> +including the additions of the Technical Specification (TS) 29113 on

> +Further Interoperability of Fortran with C and TS 18508 on Additional

> +Parallel Features in Fortran.

> 

> @item -ftest-forall-temp

> @opindex @code{ftest-forall-temp}

> @@ -782,12 +784,12 @@ other output file.

> @itemx -pedantic

> @opindex @code{pedantic}

> @opindex @code{Wpedantic}

> -Issue warnings for uses of extensions to Fortran 95.

> +Issue warnings for uses of extensions to Fortran.

> @option{-pedantic} also applies to C-language constructs where they

> occur in GNU Fortran source files, such as use of @samp{\e} in a

> character constant within a directive like @code{#include}.

> 

> -Valid Fortran 95 programs should compile properly with or without

> +Valid Fortran programs should compile properly with or without

> this option.

> However, without this option, certain GNU extensions and traditional

> Fortran features are supported as well.

> @@ -799,7 +801,7 @@ 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} or @option{-std=f2008}.

> +@option{-std=f2003}, @option{-std=f2008} or @option{-std=f2018}.

> 

> @item -pedantic-errors

> @opindex @code{pedantic-errors}

> @@ -845,12 +847,13 @@ The following example will trigger the warning.

> @opindex @code{Wampersand}

> @cindex warnings, ampersand

> @cindex @code{&}

> -Warn about missing ampersand in continued character constants. The warning is

> -given with @option{-Wampersand}, @option{-pedantic}, @option{-std=f95},

> -@option{-std=f2003} and @option{-std=f2008}. 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.

> +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

> +character constant, GNU Fortran assumes continuation at the first

> +non-comment, non-whitespace character after the ampersand that

> +initiated the continuation.

> 

> @item -Wargument-mismatch

> @opindex @code{Wargument-mismatch}

> @@ -988,10 +991,11 @@ A @code{CHARACTER} variable is declared with negative length.

> @cindex tabulators

> By default, tabs are accepted as whitespace, but tabs are not members

> 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=f2008ts} and @option{-Wall}.

> +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=f2008ts}, @option{-std=f2018} and

> +@option{-Wall}.

> 

> @item -Wundefined-do-loop

> @opindex @code{Wundefined-do-loop}

> diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt

> index 780335f..4421c0b 100644

> --- a/gcc/fortran/lang.opt

> +++ b/gcc/fortran/lang.opt

> @@ -1,4 +1,4 @@

> -; Options for the Fortran 95 front end.

> +; Options for the Fortran front end.

> ; Copyright (C) 2003-2017 Free Software Foundation, Inc.

> ;

> ; This file is part of GCC.

> @@ -802,6 +802,10 @@ std=f2008ts

> Fortran

> Conform to the ISO Fortran 2008 standard including TS 29113.

> 

> +std=f2018

> +Fortran

> +Conform to the ISO Fortran 2018 standard.

> +

> std=f95

> Fortran

> Conform to the ISO Fortran 95 standard.

> diff --git a/gcc/fortran/libgfortran.h b/gcc/fortran/libgfortran.h

> index c5ff992..0756c32 100644

> --- a/gcc/fortran/libgfortran.h

> +++ b/gcc/fortran/libgfortran.h

> @@ -22,8 +22,9 @@ along with GCC; see the file COPYING3.  If not see

>    Note that no features were obsoleted nor deleted in F2003.

>    Please remember to keep those definitions in sync with

>    gfortran.texi.  */

> -/* For now, use F2015 = GFC_STD_GNU.  */

> -#define GFC_STD_F2015	        (1<<5)	/* PLACEHOLDER for Fortran 2015.  */

> +#define GFC_STD_F2018_DEL      (1<<12)  /* Deleted in F2018.  */

> +#define GFC_STD_F2018_OBS      (1<<11)  /* Obsolescent in F2018.  */

> +#define GFC_STD_F2018          (1<<10)  /* New in F2018.  */

> #define GFC_STD_F2008_TS	(1<<9)	/* POST-F2008 technical reports.  */

> #define GFC_STD_F2008_OBS	(1<<8)	/* Obsolescent in F2008.  */

> #define GFC_STD_F2008		(1<<7)	/* New in F2008.  */

> diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c

> index c5bdce2..d63b11c 100644

> --- a/gcc/fortran/match.c

> +++ b/gcc/fortran/match.c

> @@ -2985,7 +2985,7 @@ gfc_match_stopcode (gfc_statement st)

>     {

>       if (st == ST_ERROR_STOP)

> 	{

> -	  if (!gfc_notify_std (GFC_STD_F2015, "%s statement at %C in PURE "

> +	  if (!gfc_notify_std (GFC_STD_F2018, "%s statement at %C in PURE "

> 			       "procedure", gfc_ascii_statement (st)))

> 	    goto cleanup;

> 	}

> diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c

> index 0ee6b78..57fc0f5 100644

> --- a/gcc/fortran/options.c

> +++ b/gcc/fortran/options.c

> @@ -42,7 +42,8 @@ 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_F2008_TS | GFC_STD_GNU | GFC_STD_LEGACY;

> +    | GFC_STD_F2008_OBS | GFC_STD_F2008_TS | GFC_STD_GNU | GFC_STD_LEGACY

> +    | GFC_STD_F2018 | GFC_STD_F2018_DEL | GFC_STD_F2018_OBS;

>   gfc_option.warn_std = GFC_STD_F95_DEL | GFC_STD_LEGACY;

> }

> 

> @@ -741,6 +742,17 @@ gfc_handle_option (size_t scode, const char *arg, int value,

>       warn_tabs = 1;

>       break;

> 

> +    case OPT_std_f2018:

> +      gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77

> +	| GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F2008 | GFC_STD_F2008_OBS

> +	| GFC_STD_F2008_TS | GFC_STD_F2018 | GFC_STD_F2018_OBS;

> +      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;

> +      break;

> +

>     case OPT_std_gnu:

>       set_default_std_flags ();

>       break;

> diff --git a/gcc/testsuite/gfortran.dg/error_stop_3.f90 b/gcc/testsuite/gfortran.dg/error_stop_3.f90

> index 4374739..1ff74d8 100644

> --- a/gcc/testsuite/gfortran.dg/error_stop_3.f90

> +++ b/gcc/testsuite/gfortran.dg/error_stop_3.f90

> @@ -1,8 +1,7 @@

> ! { dg-do compile }

> -! { dg-options "-std=gnu" }

> +! { dg-options "-std=f2018" }

> !

> -! F2015 permits ERROR STOP in PURE procedures

> -! FIXME: Change to -std=f2015, when available

> +! F2018 permits ERROR STOP in PURE procedures

> !

> pure subroutine foo()

>   error stop "failed"

> diff --git a/gcc/testsuite/gfortran.dg/error_stop_4.f90 b/gcc/testsuite/gfortran.dg/error_stop_4.f90

> index a28aa37..fbca599 100644

> --- a/gcc/testsuite/gfortran.dg/error_stop_4.f90

> +++ b/gcc/testsuite/gfortran.dg/error_stop_4.f90

> @@ -1,9 +1,8 @@

> ! { dg-do compile }

> ! { dg-options "-std=f2008ts" }

> !

> -! F2015 permits ERROR STOP in PURE procedures

> -! FIXME: Change to error_stop_3.f90 to -std=f2015.

> +! F2018 permits ERROR STOP in PURE procedures

> !

> pure subroutine foo()

> -  error stop "failed"  ! { dg-error "GNU Extension: ERROR STOP statement at .1. in PURE procedure" }

> +  error stop "failed"  ! { dg-error "Fortran 2018: ERROR STOP statement at .1. in PURE procedure" }

> end

> diff --git a/gcc/testsuite/gfortran.dg/implicit_14.f90 b/gcc/testsuite/gfortran.dg/implicit_14.f90

> index 5b1a3b6..b4c005b 100644

> --- a/gcc/testsuite/gfortran.dg/implicit_14.f90

> +++ b/gcc/testsuite/gfortran.dg/implicit_14.f90

> @@ -1,8 +1,8 @@

> ! { dg-do compile }

> ! { dg-options "-std=f2008ts" }

> !

> -! Support Fortran 2015's IMPLICIT NONE with spec list

> +! Support Fortran 2018's IMPLICIT NONE with spec list

> ! (currently implemented as vendor extension)

> 

> -implicit none (type) ! { dg-error "GNU Extension: IMPORT NONE with spec list at \\(1\\)" }

> +implicit none (type) ! { dg-error "Fortran 2018: IMPORT NONE with spec list at \\(1\\)" }

> end

> diff --git a/gcc/testsuite/gfortran.dg/spellcheck-procedure_2.f90 b/gcc/testsuite/gfortran.dg/spellcheck-procedure_2.f90

> index a6ea5f9..fbd4dcd 100644

> --- a/gcc/testsuite/gfortran.dg/spellcheck-procedure_2.f90

> +++ b/gcc/testsuite/gfortran.dg/spellcheck-procedure_2.f90

> @@ -3,7 +3,7 @@

> 

> 

> program spellchekc

> -  implicit none (external) ! { dg-warning "GNU Extension: IMPORT NONE with spec list" }

> +  implicit none (external)

> 

>   interface

>     subroutine bark_unless_zero(iarg)

> -- 

> 2.7.4

> 

>
Jerry DeLisle Dec. 17, 2017, 4:13 p.m. | #2
On 12/17/2017 02:02 AM, Janne Blomqvist wrote:
> The Fortran committee has decided to rename the upcoming Fortran 2015

> standard to Fortran 2018.  This is not a reflection of a three year

> delay in the process, but rather they are following other standards in

> adopting the year of publication for the name. For more details see

> N2144.

> 

> This patch renames GFC_STD_F2015 to GFC_STD_F2018, and makes it a

> separate flag rather than an alias for GFC_STD_GNU. Also, it adds a

> -std=f2018 argument, and documents it.

> 

> Regtested on x86_64-pc-linux-gnu, Ok for trunk?

> 


Yes, OK

Jerry

Patch

diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index d46083c..53a87b6 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -4114,7 +4114,7 @@  gfc_match_implicit_none (void)
   if (c == '(')
     {
       (void) gfc_next_ascii_char ();
-      if (!gfc_notify_std (GFC_STD_F2015, "IMPORT NONE with spec list at %C"))
+      if (!gfc_notify_std (GFC_STD_F2018, "IMPORT NONE with spec list at %C"))
 	return MATCH_ERROR;
 
       gfc_gobble_whitespace ();
diff --git a/gcc/fortran/error.c b/gcc/fortran/error.c
index 2cece49..f11dadc 100644
--- a/gcc/fortran/error.c
+++ b/gcc/fortran/error.c
@@ -864,6 +864,15 @@  gfc_notify_std (int std, const char *gmsgid, ...)
 
   switch (std)
   {
+    case GFC_STD_F2018_DEL:
+      msg = _("Fortran 2018 deleted feature:");
+      break;
+    case GFC_STD_F2018_OBS:
+      msg = _("Fortran 2018 obsolescent feature:");
+      break;
+    case GFC_STD_F2018:
+      msg = _("Fortran 2018:");
+      break;
     case GFC_STD_F2008_TS:
       msg = "TS 29113/TS 18508:";
       break;
diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi
index 36c7b94..aabf268 100644
--- a/gcc/fortran/gfortran.texi
+++ b/gcc/fortran/gfortran.texi
@@ -180,7 +180,7 @@  Part I: Invoking GNU Fortran
 * Runtime::              Influencing runtime behavior with environment variables.
 
 Part II: Language Reference
-* Fortran 2003 and 2008 status::  Fortran 2003 and 2008 features supported by GNU Fortran.
+* Fortran standards status::      Fortran 2003, 2008 and 2018 features supported by GNU Fortran.
 * Compiler Characteristics::      User-visible implementation details.
 * Extensions::                    Language extensions implemented by GNU Fortran.
 * Mixed-Language Programming::    Interoperability with C
@@ -243,16 +243,15 @@  or alternative to, the Unix @command{f95} command;
 @section About GNU Fortran
 
 The GNU Fortran compiler supports the Fortran 77, 90 and 95 standards
-completely, parts of the Fortran 2003 and Fortran 2008 standards, and
+completely, parts of the Fortran 2003, 2008 and 2018 standards, and
 several vendor extensions.  The development goal is to provide the
 following features:
 
 @itemize @bullet
 @item
-Read a user's program,
-stored in a file and containing instructions written
-in Fortran 77, Fortran 90, Fortran 95, Fortran 2003 or Fortran 2008.
-This file contains @dfn{source code}.
+Read a user's program, stored in a file and containing instructions
+written in Fortran 77, Fortran 90, Fortran 95, Fortran 2003, Fortran
+2008 or Fortran 2018.  This file contains @dfn{source code}.
 
 @item
 Translate the user's program into instructions a computer
@@ -504,10 +503,11 @@  G77 can be compiled with GNU Fortran, although there are a few minor known
 regressions.
 
 The primary work remaining to be done on GNU Fortran falls into three
-categories: bug fixing (primarily regarding the treatment of invalid code
-and providing useful error messages), improving the compiler optimizations
-and the performance of compiled code, and extending the compiler to support
-future standards---in particular, Fortran 2003 and Fortran 2008.
+categories: bug fixing (primarily regarding the treatment of invalid
+code and providing useful error messages), improving the compiler
+optimizations and the performance of compiled code, and extending the
+compiler to support future standards---in particular, Fortran 2003,
+Fortran 2008 and Fortran 2018.
 
 
 @c ---------------------------------------------------------------------
@@ -527,13 +527,14 @@  ISO/IEC 1539:1997 (Fortran 95).  As such, it can also compile essentially all
 standard-compliant Fortran 90 and Fortran 77 programs.   It also supports
 the ISO/IEC TR-15581 enhancements to allocatable arrays.
 
-GNU Fortran also have a partial support for ISO/IEC 1539-1:2004 (Fortran
-2003), ISO/IEC 1539-1:2010 (Fortran 2008), the Technical Specification
-@code{Further Interoperability of Fortran with C} (ISO/IEC TS 29113:2012).
-Full support of those standards and future Fortran standards is planned.
-The current status of the support is can be found in the
-@ref{Fortran 2003 status}, @ref{Fortran 2008 status}, @ref{TS 29113 status}
-and @ref{TS 18508 status} sections of the documentation.
+GNU Fortran also have a partial support for ISO/IEC 1539-1:2004
+(Fortran 2003), ISO/IEC 1539-1:2010 (Fortran 2008), the Technical
+Specification @code{Further Interoperability of Fortran with C}
+(ISO/IEC TS 29113:2012).  Full support of those standards and future
+Fortran standards is planned.  The current status of the support is
+can be found in the @ref{Fortran 2003 status}, @ref{Fortran 2008
+status}, @ref{TS 29113 status}, @ref{TS 18508 status} and @ref{Fortran
+2018 status} sections of the documentation.
 
 Additionally, the GNU Fortran compilers supports the OpenMP specification
 (version 4.0 and most of the features of the 4.5 version,
@@ -783,17 +784,18 @@  compile option was used.
 @end tex
 
 @c ---------------------------------------------------------------------
-@c Fortran 2003 and 2008 Status
+@c Fortran standards status
 @c ---------------------------------------------------------------------
 
-@node Fortran 2003 and 2008 status
-@chapter Fortran 2003 and 2008 Status
+@node Fortran standards status
+@chapter Fortran standards status
 
 @menu
 * Fortran 2003 status::
 * Fortran 2008 status::
 * TS 29113 status::
 * TS 18508 status::
+* Fortran 2018 status::
 @end menu
 
 @node Fortran 2003 status
@@ -1145,6 +1147,27 @@  polymorphic components.
 @end itemize
 
 
+@node Fortran 2018 status
+@section Status of Fortran 2018 support
+
+So far very little work has been done to support Fortran 2018.
+
+@itemize
+@item ERROR STOP in a PURE procedure
+An @code{ERROR STOP} statement is permitted in a @code{PURE}
+procedure.
+
+@item IMPLICIT NONE with a spec-list
+Support the @code{IMPLICIT NONE} statement with an
+@code{implicit-none-spec-list}.
+
+@item Behavior of INQUIRE with the RECL= specifier
+
+The behavior of the @code{INQUIRE} statement with the @code{RECL=}
+specifier now conforms to Fortran 2018.
+
+@end itemize
+
 @c ---------------------------------------------------------------------
 @c Compiler Characteristics
 @c ---------------------------------------------------------------------
@@ -1482,18 +1505,19 @@  extensions.
 @section Extensions implemented in GNU Fortran
 @cindex extensions, implemented
 
-GNU Fortran implements a number of extensions over standard
-Fortran.  This chapter contains information on their syntax and
-meaning.  There are currently two categories of GNU Fortran
-extensions, those that provide functionality beyond that provided
-by any standard, and those that are supported by GNU Fortran
-purely for backward compatibility with legacy compilers.  By default,
-@option{-std=gnu} allows the compiler to accept both types of
-extensions, but to warn about the use of the latter.  Specifying
-either @option{-std=f95}, @option{-std=f2003} or @option{-std=f2008}
-disables both types of extensions, and @option{-std=legacy} allows both
-without warning.  The special compile flag @option{-fdec} enables additional
-compatibility extensions along with those enabled by @option{-std=legacy}.
+GNU Fortran implements a number of extensions over standard Fortran.
+This chapter contains information on their syntax and meaning.  There
+are currently two categories of GNU Fortran extensions, those that
+provide functionality beyond that provided by any standard, and those
+that are supported by GNU Fortran purely for backward compatibility
+with legacy compilers.  By default, @option{-std=gnu} allows the
+compiler to accept both types of extensions, but to warn about the use
+of the latter.  Specifying either @option{-std=f95},
+@option{-std=f2003}, @option{-std=f2008}, or @option{-std=f2018}
+disables both types of extensions, and @option{-std=legacy} allows
+both without warning.  The special compile flag @option{-fdec} enables
+additional compatibility extensions along with those enabled by
+@option{-std=legacy}.
 
 @menu
 * Old-style kind specifications::
@@ -3602,15 +3626,17 @@  used.
 @item @emph{option flag list}:
 @multitable @columnfractions .15 .70
 @item @var{option}[0] @tab Allowed standard; can give run-time errors
-if e.g. an input-output edit descriptor is invalid in a given standard.
-Possible values are (bitwise or-ed) @code{GFC_STD_F77} (1),
-@code{GFC_STD_F95_OBS} (2), @code{GFC_STD_F95_DEL} (4), @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) and GFC_STD_F2008_TS (512). 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_GNU | GFC_STD_LEGACY}.
+if e.g. an input-output edit descriptor is invalid in a given
+standard.  Possible values are (bitwise or-ed) @code{GFC_STD_F77} (1),
+@code{GFC_STD_F95_OBS} (2), @code{GFC_STD_F95_DEL} (4),
+@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}.
 @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/interface.c b/gcc/fortran/interface.c
index 1b7ebf5..cd02214 100644
--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -2355,7 +2355,7 @@  compare_parameter (gfc_symbol *formal, gfc_expr *actual,
   if (formal->attr.codimension)
     {
       /* F2008, 12.5.2.8 + Corrig 2 (IR F08/0048).  */
-      /* F2015, 12.5.2.8.  */
+      /* F2018, 12.5.2.8.  */
       if (formal->attr.dimension
 	  && (formal->attr.contiguous || formal->as->type != AS_ASSUMED_SHAPE)
 	  && actual_attr.dimension
diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi
index f3a8b34..7b6f161 100644
--- a/gcc/fortran/invoke.texi
+++ b/gcc/fortran/invoke.texi
@@ -467,22 +467,24 @@  representation of the translated Fortran code, produced by
 
 @item -std=@var{std}
 @opindex @code{std=}@var{std} option
-Specify the standard to which the program is expected to conform, which
-may be one of @samp{f95}, @samp{f2003}, @samp{f2008}, @samp{gnu}, or
-@samp{legacy}.  The default value for @var{std} is @samp{gnu}, which
-specifies a superset of the Fortran 95 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} and @samp{f2008} values specify strict
-conformance to the Fortran 95, Fortran 2003 and Fortran 2008 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. @samp{-std=f2008ts}
-allows the Fortran 2008 standard including the additions of the 
-Technical Specification (TS) 29113 on Further Interoperability of Fortran
-with C and TS 18508 on Additional Parallel Features in Fortran.
+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
+@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
+beyond the relevant language standard, and warnings are given for the
+Fortran 77 features that are permitted but obsolescent in later
+standards. @samp{-std=f2008ts} allows the Fortran 2008 standard
+including the additions of the Technical Specification (TS) 29113 on
+Further Interoperability of Fortran with C and TS 18508 on Additional
+Parallel Features in Fortran.
 
 @item -ftest-forall-temp
 @opindex @code{ftest-forall-temp}
@@ -782,12 +784,12 @@  other output file.
 @itemx -pedantic
 @opindex @code{pedantic}
 @opindex @code{Wpedantic}
-Issue warnings for uses of extensions to Fortran 95.
+Issue warnings for uses of extensions to Fortran.
 @option{-pedantic} also applies to C-language constructs where they
 occur in GNU Fortran source files, such as use of @samp{\e} in a
 character constant within a directive like @code{#include}.
 
-Valid Fortran 95 programs should compile properly with or without
+Valid Fortran programs should compile properly with or without
 this option.
 However, without this option, certain GNU extensions and traditional
 Fortran features are supported as well.
@@ -799,7 +801,7 @@  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} or @option{-std=f2008}.
+@option{-std=f2003}, @option{-std=f2008} or @option{-std=f2018}.
 
 @item -pedantic-errors
 @opindex @code{pedantic-errors}
@@ -845,12 +847,13 @@  The following example will trigger the warning.
 @opindex @code{Wampersand}
 @cindex warnings, ampersand
 @cindex @code{&}
-Warn about missing ampersand in continued character constants. The warning is
-given with @option{-Wampersand}, @option{-pedantic}, @option{-std=f95},
-@option{-std=f2003} and @option{-std=f2008}. 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.
+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
+character constant, GNU Fortran assumes continuation at the first
+non-comment, non-whitespace character after the ampersand that
+initiated the continuation.
 
 @item -Wargument-mismatch
 @opindex @code{Wargument-mismatch}
@@ -988,10 +991,11 @@  A @code{CHARACTER} variable is declared with negative length.
 @cindex tabulators
 By default, tabs are accepted as whitespace, but tabs are not members
 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=f2008ts} and @option{-Wall}.
+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=f2008ts}, @option{-std=f2018} and
+@option{-Wall}.
 
 @item -Wundefined-do-loop
 @opindex @code{Wundefined-do-loop}
diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
index 780335f..4421c0b 100644
--- a/gcc/fortran/lang.opt
+++ b/gcc/fortran/lang.opt
@@ -1,4 +1,4 @@ 
-; Options for the Fortran 95 front end.
+; Options for the Fortran front end.
 ; Copyright (C) 2003-2017 Free Software Foundation, Inc.
 ;
 ; This file is part of GCC.
@@ -802,6 +802,10 @@  std=f2008ts
 Fortran
 Conform to the ISO Fortran 2008 standard including TS 29113.
 
+std=f2018
+Fortran
+Conform to the ISO Fortran 2018 standard.
+
 std=f95
 Fortran
 Conform to the ISO Fortran 95 standard.
diff --git a/gcc/fortran/libgfortran.h b/gcc/fortran/libgfortran.h
index c5ff992..0756c32 100644
--- a/gcc/fortran/libgfortran.h
+++ b/gcc/fortran/libgfortran.h
@@ -22,8 +22,9 @@  along with GCC; see the file COPYING3.  If not see
    Note that no features were obsoleted nor deleted in F2003.
    Please remember to keep those definitions in sync with
    gfortran.texi.  */
-/* For now, use F2015 = GFC_STD_GNU.  */
-#define GFC_STD_F2015	        (1<<5)	/* PLACEHOLDER for Fortran 2015.  */
+#define GFC_STD_F2018_DEL      (1<<12)  /* Deleted in F2018.  */
+#define GFC_STD_F2018_OBS      (1<<11)  /* Obsolescent in F2018.  */
+#define GFC_STD_F2018          (1<<10)  /* New in F2018.  */
 #define GFC_STD_F2008_TS	(1<<9)	/* POST-F2008 technical reports.  */
 #define GFC_STD_F2008_OBS	(1<<8)	/* Obsolescent in F2008.  */
 #define GFC_STD_F2008		(1<<7)	/* New in F2008.  */
diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
index c5bdce2..d63b11c 100644
--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -2985,7 +2985,7 @@  gfc_match_stopcode (gfc_statement st)
     {
       if (st == ST_ERROR_STOP)
 	{
-	  if (!gfc_notify_std (GFC_STD_F2015, "%s statement at %C in PURE "
+	  if (!gfc_notify_std (GFC_STD_F2018, "%s statement at %C in PURE "
 			       "procedure", gfc_ascii_statement (st)))
 	    goto cleanup;
 	}
diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
index 0ee6b78..57fc0f5 100644
--- a/gcc/fortran/options.c
+++ b/gcc/fortran/options.c
@@ -42,7 +42,8 @@  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_F2008_TS | GFC_STD_GNU | GFC_STD_LEGACY;
+    | GFC_STD_F2008_OBS | GFC_STD_F2008_TS | GFC_STD_GNU | GFC_STD_LEGACY
+    | GFC_STD_F2018 | GFC_STD_F2018_DEL | GFC_STD_F2018_OBS;
   gfc_option.warn_std = GFC_STD_F95_DEL | GFC_STD_LEGACY;
 }
 
@@ -741,6 +742,17 @@  gfc_handle_option (size_t scode, const char *arg, int value,
       warn_tabs = 1;
       break;
 
+    case OPT_std_f2018:
+      gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F77
+	| GFC_STD_F2003 | GFC_STD_F95 | GFC_STD_F2008 | GFC_STD_F2008_OBS
+	| GFC_STD_F2008_TS | GFC_STD_F2018 | GFC_STD_F2018_OBS;
+      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;
+      break;
+
     case OPT_std_gnu:
       set_default_std_flags ();
       break;
diff --git a/gcc/testsuite/gfortran.dg/error_stop_3.f90 b/gcc/testsuite/gfortran.dg/error_stop_3.f90
index 4374739..1ff74d8 100644
--- a/gcc/testsuite/gfortran.dg/error_stop_3.f90
+++ b/gcc/testsuite/gfortran.dg/error_stop_3.f90
@@ -1,8 +1,7 @@ 
 ! { dg-do compile }
-! { dg-options "-std=gnu" }
+! { dg-options "-std=f2018" }
 !
-! F2015 permits ERROR STOP in PURE procedures
-! FIXME: Change to -std=f2015, when available
+! F2018 permits ERROR STOP in PURE procedures
 !
 pure subroutine foo()
   error stop "failed"
diff --git a/gcc/testsuite/gfortran.dg/error_stop_4.f90 b/gcc/testsuite/gfortran.dg/error_stop_4.f90
index a28aa37..fbca599 100644
--- a/gcc/testsuite/gfortran.dg/error_stop_4.f90
+++ b/gcc/testsuite/gfortran.dg/error_stop_4.f90
@@ -1,9 +1,8 @@ 
 ! { dg-do compile }
 ! { dg-options "-std=f2008ts" }
 !
-! F2015 permits ERROR STOP in PURE procedures
-! FIXME: Change to error_stop_3.f90 to -std=f2015.
+! F2018 permits ERROR STOP in PURE procedures
 !
 pure subroutine foo()
-  error stop "failed"  ! { dg-error "GNU Extension: ERROR STOP statement at .1. in PURE procedure" }
+  error stop "failed"  ! { dg-error "Fortran 2018: ERROR STOP statement at .1. in PURE procedure" }
 end
diff --git a/gcc/testsuite/gfortran.dg/implicit_14.f90 b/gcc/testsuite/gfortran.dg/implicit_14.f90
index 5b1a3b6..b4c005b 100644
--- a/gcc/testsuite/gfortran.dg/implicit_14.f90
+++ b/gcc/testsuite/gfortran.dg/implicit_14.f90
@@ -1,8 +1,8 @@ 
 ! { dg-do compile }
 ! { dg-options "-std=f2008ts" }
 !
-! Support Fortran 2015's IMPLICIT NONE with spec list
+! Support Fortran 2018's IMPLICIT NONE with spec list
 ! (currently implemented as vendor extension)
 
-implicit none (type) ! { dg-error "GNU Extension: IMPORT NONE with spec list at \\(1\\)" }
+implicit none (type) ! { dg-error "Fortran 2018: IMPORT NONE with spec list at \\(1\\)" }
 end
diff --git a/gcc/testsuite/gfortran.dg/spellcheck-procedure_2.f90 b/gcc/testsuite/gfortran.dg/spellcheck-procedure_2.f90
index a6ea5f9..fbd4dcd 100644
--- a/gcc/testsuite/gfortran.dg/spellcheck-procedure_2.f90
+++ b/gcc/testsuite/gfortran.dg/spellcheck-procedure_2.f90
@@ -3,7 +3,7 @@ 
 
 
 program spellchekc
-  implicit none (external) ! { dg-warning "GNU Extension: IMPORT NONE with spec list" }
+  implicit none (external)
 
   interface
     subroutine bark_unless_zero(iarg)