GCC Bugzilla – Bug 17590
Standard conformance should take intrinsics into account.
Last modified: 2004-11-10 02:25:46 UTC
To be able to be really anal about standard conformance, we need to distinguish between intrinsics which were added in F77, F95, F2003 or whether they are GNU specific intrinsics.
Confirmed, I thought there was another bug for this but there is not.
Proposed patch here: http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02291.html
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02291.html>.
Here is the revised patch, which for some reason isn't flagged as belonging to the same thread as the original: http://gcc.gnu.org/ml/gcc-patches/2004-10/msg00829.html
Subject: Bug 17590 CVSROOT: /cvs/gcc Module name: gcc Changes by: pbrook@gcc.gnu.org 2004-10-31 01:24:30 Modified files: gcc/fortran : ChangeLog gfortran.h intrinsic.c invoke.texi lang.opt options.c Log message: 2004-10-31 Janne Blomqvist <jblomqvi@cc.hut.fi> PR fortran/17590 * gfortran.h: Change GFC_STD_* flags to more appropriate ones. (struct gfc_intrinsic_isym): Add field for standard. (struct gfc_option_t): Add field for warning about use of nonstandard intrinsics. * intrinsic.c (add_sym): Add parameter for standard version, check this against current standard. (add_sym_0): Pass standard parameter to add_sym. (add_sym_1, add_sym_0s, add_sym_1s, add_sym_1m, add_sym_2): Ditto. (add_sym_2s, add_sym_3, add_sym_3ml, add_sym_3red, add_sym_3s): Ditto. (add_sym_4, add_sym_4s, add_sym_5, add_sym_5s): Ditto. (make_generic): Add parameter for standard, check this against currently selected standard. (add_functions, add_subroutines): Add parameter to tell which standard an intrinsic belongs to. (check_intrinsic_standard): New function. (gfc_intrinsic_func_interface): Add call to check_intrinsic_standard. (gfc_intrinsic_sub_interface): Ditto. * lang.opt: Add Wnonstd-intrinsics option. * options.c (gfc_init_options): Change to use new GFC_STD_* flags, init new warning. (set_Wall): Add warning about nonstd intrinsics. (gfc_handle_option): Change to use new GFC_STD_* flags, handle new warning. * invoke.texi: Update manual to include -Wnonstd-intrinsics. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/ChangeLog.diff?cvsroot=gcc&r1=1.244&r2=1.245 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/gfortran.h.diff?cvsroot=gcc&r1=1.40&r2=1.41 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/intrinsic.c.diff?cvsroot=gcc&r1=1.26&r2=1.27 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/invoke.texi.diff?cvsroot=gcc&r1=1.5&r2=1.6 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/lang.opt.diff?cvsroot=gcc&r1=1.7&r2=1.8 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/options.c.diff?cvsroot=gcc&r1=1.12&r2=1.13
Fixed.
I'm reopening this PR since a bug crept in, apparently Paul changed the code to be C89 conformant while it depended on C99 VLA:s to function properly. If you look at intrinsic.c:check_intrinsic_standard you see that originally it contained: int name_len; name_len = strlen(name); char msgstr[name_len + 53]; while the committed version has: int name_len; char msgstr[name_len + 53]; i.e. msgstr is allocated before the correct length is known. I'll try to fix it asap with some __builtin_alloca magic..
Subject: Re: Standard conformance should take intrinsics into account. All, FWIW here's a quick patch which fixes bootstrap problem for me on i686-pc-linux-gnu. I've got to go out the door in 5 mins do with as you see fit. Graham ---------------------------------------------------------------------------------------- Index: intrinsic.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/fortran/intrinsic.c,v retrieving revision 1.27 diff -c -p -r1.27 intrinsic.c *** intrinsic.c 31 Oct 2004 01:24:29 -0000 1.27 --- intrinsic.c 31 Oct 2004 14:46:19 -0000 *************** gfc_init_expr_extensions (gfc_intrinsic_ *** 2672,2687 **** static void check_intrinsic_standard (const char *name, int standard) { ! int name_len; ! char msgstr[name_len + 53]; ! ! if (!gfc_option.warn_nonstd_intrinsics) ! return; ! ! name_len = strlen (name); ! strncpy (msgstr, name, name_len + 1); ! strncat (msgstr, " intrinsic is not included in the selected standard.", 53); ! gfc_notify_std (standard, msgstr); } --- 2671,2688 ---- static void check_intrinsic_standard (const char *name, int standard) { ! if (gfc_option.warn_nonstd_intrinsics) ! { ! static const char err[] = " intrinsic is not included in the selected standard."; ! size_t err_len = sizeof (err); ! size_t name_len = strlen (name); ! char *msgstr = gfc_getmem (name_len + err_len); ! ! memcpy (msgstr, name, name_len); ! memcpy (&msgstr[name_len], err, err_len); ! gfc_notify_std (standard, msgstr); ! gfc_free (msgstr); ! } } ----------------------------------------------------------------------------------------
Ok, my patch is here: http://gcc.gnu.org/ml/gcc-patches/2004-10/msg02748.html The only major difference compared to Graham's patch is the use of __builtin_alloca instead of gfc_getmem.
*** Bug 18261 has been marked as a duplicate of this bug. ***