This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [gfortran] Silence GNU extension warnings with -std=gnu
- From: Roger Sayle <roger at eyesopen dot com>
- To: Paul Brook <paul at codesourcery dot com>
- Cc: fortran at gcc dot gnu dot org, <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 23 May 2004 13:18:56 -0600 (MDT)
- Subject: Re: [gfortran] Silence GNU extension warnings with -std=gnu
On Sun, 23 May 2004, Paul Brook wrote:
> No, or at least not in its current form. This patch introduces a fourth
> "standard" variant. It's no longer possible to explicitly select the
> default.
Unfortunately, its already the case that gfortran has a fourth standard
and its already impossible to select the default. By default, we don't
warn about F2003 deleted and obsoleted features, but with -std=gnu, we
do. But it sounds from your review that this is unintentional. If
someone could make a determination of what the correct behaviour should
be, I'll be happy to propose a patch to "make it so".
> Maybe it would be better to introduce new option (eg. -Wnonstandard or
> -Wextension) to disable these warnings? Either that or tie them to
> -pedantic.
Ok, here's a variation of my original patch that ties these warnings to
-pedantic, but keeps the behaviour of GNU extensions identical between
the default and -std=gnu settings. With this patch, neither of these
standards complain about use of GNU extensions, unless the user specifies
-pedantic (or uses -std=f95/-std=f2003 where they become hard errors).
I believe this is closer to the how the C/C++/ObjC front-ends do things.
The following patch has been tested with i686-pc-linux-gnu with a full
bootstrap, including gfortran, and regression tested with a top-level
"make -k check" with no new failures.
2004-05-23 Roger Sayle <roger@eyesopen.com>
* options.c (gfc_init_options): Don't warn about the use GNU
extensions by default.
(gfc_post_options): Warn about GNU extensions with -pedantic.
(gfc_handle_option): Don't warn about GNU extensions with -std=gnu.
Index: options.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/options.c,v
retrieving revision 1.4
diff -c -3 -p -r1.4 options.c
*** options.c 16 May 2004 21:10:24 -0000 1.4
--- options.c 23 May 2004 15:02:18 -0000
*************** gfc_init_options (unsigned int argc ATTR
*** 79,85 ****
gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
| GFC_STD_F2003_OBS | GFC_STD_F2003_DEL | GFC_STD_F2003 | GFC_STD_GNU;
gfc_option.warn_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
! | GFC_STD_F2003 | GFC_STD_GNU;
return CL_F95;
}
--- 79,85 ----
gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
| GFC_STD_F2003_OBS | GFC_STD_F2003_DEL | GFC_STD_F2003 | GFC_STD_GNU;
gfc_option.warn_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
! | GFC_STD_F2003;
return CL_F95;
}
*************** gfc_post_options (const char **pfilename
*** 110,116 ****
flag_inline_trees = 2;
flag_inline_functions = 0;
}
!
return false;
}
--- 110,120 ----
flag_inline_trees = 2;
flag_inline_functions = 0;
}
!
! /* If -pedantic, warn about the use of GNU extensions. */
! if (pedantic && (gfc_option.allow_std & GFC_STD_GNU) != 0)
! gfc_option.warn_std |= GFC_STD_GNU;
!
return false;
}
*************** gfc_handle_option (size_t scode, const c
*** 313,319 ****
gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
| GFC_STD_F2003_OBS | GFC_STD_F2003_DEL | GFC_STD_F2003 | GFC_STD_GNU;
gfc_option.warn_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
! | GFC_STD_F2003_OBS | GFC_STD_F2003_DEL | GFC_STD_GNU;
break;
}
--- 317,323 ----
gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
| GFC_STD_F2003_OBS | GFC_STD_F2003_DEL | GFC_STD_F2003 | GFC_STD_GNU;
gfc_option.warn_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL
! | GFC_STD_F2003_OBS | GFC_STD_F2003_DEL;
break;
}
Roger
--