https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84382
--- Comment #5 from Steve Kargl <sgk at troutmask dot apl.washington.edu> --- On Fri, Apr 05, 2019 at 10:24:15AM +0000, janus at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84382 > > --- Comment #4 from janus at gcc dot gnu.org --- > (In reply to kargl from comment #3) > > How do you propose to enforce a certain standard and allow > > GNU extensions? For example, -std=gnu2003 would enforce > > Fortran 2003, but allow GNU extensions. The problem is that > > gfortran allows several extensions that violate the > > standard. > > The idea is that -std=gnu2003 would allow 2003 features plus GNU extensions, > but reject any 2008 and 2018 features (like submodules and coarrays). > I see. It seems counter-intuitive to me for someone to want, for example, -std=gnu2003, which accepts the garbage that GFC_STD_GNU permits, F2003 conformance, and suppresses F2008 and F2018. I would rather have gfortran encourage programmers to write standard conforming code. In any event, looking at fortran/libgfortran.h, we have #define GFC_STD_OPT_F95 (GFC_STD_F77 | GFC_STD_F95 | GFC_STD_F95_OBS \ | GFC_STD_F2008_OBS | GFC_STD_F2018_OBS \ | GFC_STD_F2018_DEL) #define GFC_STD_OPT_F03 (GFC_STD_OPT_F95 | GFC_STD_F2003) #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)) We could add #define GFC_STD_OPT_GNU03 (GFC_STD_OPT_F03 | GFC_STD_GNU) #define GFC_STD_OPT_GNU08 (GFC_STD_OPT_F08 | GFC_STD_GNU) #define GFC_STD_OPT_GNU18 (GFC_STD_OPT_F18 | GFC_STD_GNU) then in options.c (gfc_handle_options) the case statements would be case OPT_std_gnu2003: gfc_option.allow_std = GFC_STD_OPT_GNU03; gfc_option.warn_std = GFC_STD_F95_OBS; gfc_option.max_identifier_length = 63; warn_ampersand = 1; warn_tabs = 1; break; case OPT_std_gnu2008: gfc_option.allow_std = GFC_STD_OPT_GNU08; gfc_option.warn_std = GFC_STD_F95_OBS | GFC_STD_F2008_OBS; gfc_option.max_identifier_length = 63; warn_ampersand = 1; warn_tabs = 1; break; case OPT_std_gnu2018: 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_identifier_length = 63; warn_ampersand = 1; warn_tabs = 1; break; then finally lang.opt (and of course documentation would add) std=gnu2003 Fortran Conform to the ISO Fortran 2003 standard with GNU Fortran extensions. std=gnu2008 Fortran Conform to the ISO Fortran 2008 standard with GNU Fortran extensions. std=gnu2018 Fortran Conform to the ISO Fortran 2018 standard with GNU Fortran extensions.