This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[patch, fortran] PR32778 - pedantic warning: intrinsics that are GNU extensions not part of -std=gnu
- From: Daniel Franke <franke dot daniel at gmail dot com>
- To: fortran at gcc dot gnu dot org
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sat, 21 Jul 2007 19:45:36 +0200
- Subject: [patch, fortran] PR32778 - pedantic warning: intrinsics that are GNU extensions not part of -std=gnu
- Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:from:to:subject:date:user-agent:cc:mime-version:content-type:message-id; b=N04sO126WskDd6AFJb21Jog5I9iST+S9fya8uDLdXZz6ta1R95x1H7S3UmMTqKzeq6VbxJo+Hr3LZneMJ5hRgecNSJb8Y0abxXz9KJ+XAx33fj4j55BsfNiaYIWSg9GNzeVBJlS8dar4+Wrg8/BWaZgItqO4xji24BswH+aA3iQ=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:from:to:subject:date:user-agent:cc:mime-version:content-type:message-id; b=SS2xMeKi3dWpb2ktW+cvW6scyDctZhY9MyEU63rHTYhNGXDXGwq8cg8Ijv+c6GiUT59FRRXj3OzC5sd6gMYrVrS68bueBkz+FwJItfPrG+ebc+wWkjitPSriXWGA1GkLKwx4wzMhdSUMWQSHc02PPrvjv9AH0eE2xnrEUf/kZTY=
$> cat pr32778.f90
CALL flush()
end
$> gfortran-svn -Wnonstd-intrinsics -pedantic -std=gnu pedantic.f90
pr32778.f90:1.12:
CALL flush()
1
Warning: Intrinsic 'flush' at (1) is not included in the selected standard
... which is strange as the docs state that FLUSH is a GNU extension?!
Digging deeper, one finds that
(a) this warning is only issued with -pedantic
(b) only for GNU extensions
I.e. the only error issued for GNU extensions and intrinsics defined by F2003
if -std=f95, is a linker error.
Attached patch fixes this by
(a) always filling the list of intrinsics with all available symbols,
regardless of the corresponding standard
(b) properly admitting for a newly introduced try-value after checking the
standard-conformity
:ADDPATCH fortran:
gcc/fortran:
2007-07-21 Daniel Franke <franke.daniel@gmail.com>
PR fortran/32778
* intrinsic.c (add_sym): Do not exclude any symbols, even if not part
of the selected standard.
(make generic): Likewise.
(make alias): Likewise, set standard the alias belongs to.
(check_intrinsic_standard): Change return value to try.
(gfc_intrinsic_func_interface): Check return value of above function.
(gfc_intrinsic_sub_interface): Likewise.
gcc/testsuite:
2007-07-21 Daniel Franke <franke.daniel@gmail.com>
PR fortran/32778
* gfortran.dg/imag_2.f: Removed
* gfortran.dg/warn_std_1.f90: New test.
* gfortran.dg/warn_std_2.f90: New test.
* gfortran.dg/warn_std_3.f90: New test.
The test imag_2.f was removed as it essentially tests the same as the
warn_std_* tests, only less extensive.
Regression tested on i686-pc-linux-gnu. Ok for trunk?
Regards
Daniel
Index: fortran/intrinsic.c
===================================================================
--- fortran/intrinsic.c (revision 126788)
+++ fortran/intrinsic.c (working copy)
@@ -228,12 +228,6 @@
int optional, first_flag;
va_list argp;
- /* First check that the intrinsic belongs to the selected standard.
- If not, don't add it to the symbol list. */
- if (!(gfc_option.allow_std & standard)
- && gfc_option.flag_all_intrinsics == 0)
- return;
-
switch (sizing)
{
case SZ_SUBS:
@@ -803,17 +797,18 @@
The first argument is the name of the generic function, which is
also the name of a specific function. The rest of the specifics
currently in the table are placed into the list of specific
- functions associated with that generic. */
+ functions associated with that generic.
+ PR fortran/32778
+ FIXME: Remove the argument STANDARD if no regressions are
+ encountered. Change all callers (approx. 360).
+*/
+
static void
-make_generic (const char *name, gfc_isym_id id, int standard)
+make_generic (const char *name, gfc_isym_id id, int standard ATTRIBUTE_UNUSED)
{
gfc_intrinsic_sym *g;
- if (!(gfc_option.allow_std & standard)
- && gfc_option.flag_all_intrinsics == 0)
- return;
-
if (sizing != SZ_NOTHING)
return;
@@ -845,19 +840,14 @@
/* Create a duplicate intrinsic function entry for the current
- function, the only difference being the alternate name. Note that
- we use argument lists more than once, but all argument lists are
- freed as a single block. */
+ function, the only differences being the alternate name and
+ a different standard if necessary. Note that we use argument
+ lists more than once, but all argument lists are freed as a
+ single block. */
static void
make_alias (const char *name, int standard)
{
- /* First check that the intrinsic belongs to the selected standard.
- If not, don't add it to the symbol list. */
- if (!(gfc_option.allow_std & standard)
- && gfc_option.flag_all_intrinsics == 0)
- return;
-
switch (sizing)
{
case SZ_FUNCS:
@@ -871,6 +861,7 @@
case SZ_NOTHING:
next_sym[0] = next_sym[-1];
next_sym->name = gfc_get_string (name);
+ next_sym->standard = standard;
next_sym++;
break;
@@ -3297,14 +3288,19 @@
/* Check whether an intrinsic belongs to whatever standard the user
has chosen. */
-static void
+static try
check_intrinsic_standard (const char *name, int standard, locus *where)
{
- if (!gfc_option.warn_nonstd_intrinsics)
- return;
+ /* Do not warn about GNU-extensions if -std=gnu. */
+ if (!gfc_option.warn_nonstd_intrinsics
+ || (standard == GFC_STD_GNU && gfc_option.warn_std & GFC_STD_GNU))
+ return SUCCESS;
- gfc_notify_std (standard, "Intrinsic '%s' at %L is not included "
- "in the selected standard", name, where);
+ if (gfc_notify_std (standard, "Intrinsic '%s' at %L is not included "
+ "in the selected standard", name, where) == FAILURE)
+ return FAILURE;
+
+ return SUCCESS;
}
@@ -3350,6 +3346,9 @@
return MATCH_NO;
}
+ if (check_intrinsic_standard (name, isym->standard, &expr->where) == FAILURE)
+ return MATCH_ERROR;
+
gfc_current_intrinsic_where = &expr->where;
/* Bypass the generic list for min and max. */
@@ -3413,8 +3412,6 @@
}
}
- check_intrinsic_standard (name, isym->standard, &expr->where);
-
return MATCH_YES;
}
@@ -3436,6 +3433,9 @@
if (isym == NULL)
return MATCH_NO;
+ if (check_intrinsic_standard (name, isym->standard, &c->loc) == FAILURE)
+ return MATCH_ERROR;
+
gfc_suppress_error = !error_flag;
init_arglist (isym);
@@ -3471,7 +3471,6 @@
}
c->resolved_sym->attr.noreturn = isym->noreturn;
- check_intrinsic_standard (name, isym->standard, &c->loc);
return MATCH_YES;
Index: testsuite/gfortran.dg/imag_2.f
===================================================================
--- testsuite/gfortran.dg/imag_2.f (revision 126704)
+++ testsuite/gfortran.dg/imag_2.f (working copy)
@@ -1,15 +0,0 @@
-! { dg-do compile }
-! { dg-options "-std=f95" }
- program bug
- implicit none
- complex(kind=8) z
- double precision x
- z = cmplx(1.e0_8, 2.e0_8)
- x = imag(z) ! { dg-error "has no IMPLICIT type" "" }
- x = imagpart(z) ! { dg-error "has no IMPLICIT type" "" }
- x = realpart(z) ! { dg-error "has no IMPLICIT type" "" }
- x = imag(x) ! { dg-error "has no IMPLICIT type" "" }
- x = imagpart(x) ! { dg-error "has no IMPLICIT type" "" }
- x = realpart(x) ! { dg-error "has no IMPLICIT type" "" }
- end
-
Index: testsuite/gfortran.dg/warn_std_1.f90
===================================================================
--- testsuite/gfortran.dg/warn_std_1.f90 (revision 0)
+++ testsuite/gfortran.dg/warn_std_1.f90 (revision 0)
@@ -0,0 +1,25 @@
+! { dg-do compile }
+! { dg-options "-Wnonstd-intrinsics -std=gnu" }
+!
+! PR fortran/32778 - pedantic warning: intrinsics that
+! are GNU extensions not part of -std=gnu
+!
+! (1/3) Check for excess errors if -std=gnu.
+!
+
+CHARACTER(len=255) :: tmp
+REAL(8) :: x
+
+! GNU extension, check overload of F77 standard intrinsic
+x = ZABS(CMPLX(0.0, 1.0, 8))
+
+! GNU extension
+CALL flush()
+
+! F95
+tmp = ADJUSTL(" gfortran ")
+
+! F2003
+CALL GET_COMMAND (tmp)
+
+END
Index: testsuite/gfortran.dg/warn_std_2.f90
===================================================================
--- testsuite/gfortran.dg/warn_std_2.f90 (revision 0)
+++ testsuite/gfortran.dg/warn_std_2.f90 (revision 0)
@@ -0,0 +1,25 @@
+! { dg-do compile }
+! { dg-options "-Wnonstd-intrinsics -std=f95" }
+!
+! PR fortran/32778 - pedantic warning: intrinsics that
+! are GNU extensions not part of -std=gnu
+!
+! (2/3) Check for GNU extensions and intrinsics from F2003 if -std=f95.
+!
+
+CHARACTER(len=255) :: tmp
+REAL(8) :: x
+
+! GNU extension, check overload of F77 standard intrinsic
+x = ZABS(CMPLX(0.0, 1.0, 8)) ! { dg-error "is not included in the selected standard" }
+
+! GNU extension
+CALL flush() ! { dg-error "is not included in the selected standard" }
+
+! F95
+tmp = ADJUSTL(" gfortran ")
+
+! F2003
+CALL GET_COMMAND (tmp) ! { dg-error "is not included in the selected standard" }
+
+END
Index: testsuite/gfortran.dg/warn_std_3.f90
===================================================================
--- testsuite/gfortran.dg/warn_std_3.f90 (revision 0)
+++ testsuite/gfortran.dg/warn_std_3.f90 (revision 0)
@@ -0,0 +1,25 @@
+! { dg-do compile }
+! { dg-options "-Wnonstd-intrinsics -std=f2003" }
+!
+! PR fortran/32778 - pedantic warning: intrinsics that
+! are GNU extensions not part of -std=gnu
+!
+! (3/3) Check for GNU extensions if -std=f2003.
+!
+
+CHARACTER(len=255) :: tmp
+REAL(8) :: x
+
+! GNU extension, check overload of F77 standard intrinsic
+x = ZABS(CMPLX(0.0, 1.0, 8)) ! { dg-error "is not included in the selected standard" }
+
+! GNU extension
+CALL flush() ! { dg-error "is not included in the selected standard" }
+
+! F95
+tmp = ADJUSTL(" gfortran ")
+
+! F2003
+CALL GET_COMMAND (tmp)
+
+END