This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch, Fortran] PR 40041 - Remove spurious warning about typing intrinsic functions
- From: Tobias Burnus <burnus at net-b dot de>
- To: gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Date: Wed, 6 May 2009 17:05:55 +0200
- Subject: [Patch, Fortran] PR 40041 - Remove spurious warning about typing intrinsic functions
This patch is close to being obvious. Currently, a valid warning
is printed for
intrinsic abs
real abs
as "abs" cannot really be typed as its generic interfaces are known.
The warning was added by Daniel Franke with Rev. 126153 for PR 20373.
However, as Daniel Franke has just reported (PR 40041), it one
does not use IMPLICIT NONE and if one uses the intrinsic function,
the function 'ABS' gets implicitly typed - and the warning gets
thus also printed for
intrinsic abs
a = abs(b)
which is wrong.
The solution is obvious: Only warn if an intrinsic function has
explicitly typed.
Bootstrapped on x86_64-linux and regtesting being performed.
OK for the trunk? (Assuming no testsuite failure.)
Tobias
2009-05-06 Tobias Burnus <burnus@net-b.de>
PR fortran/40041
* resolve.c (resolve_symbol): Print no warning for implicitly
typed intrinsic functions.
2009-05-06 Tobias Burnus <burnus@net-b.de>
PR fortran/40041
* gfortran.dg/intrinsic_2.f90: New test.
* gfortran.dg/intrinsic.f90: Add old and this PR as comment.
Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c (revision 147171)
+++ gcc/fortran/resolve.c (working copy)
@@ -9320,13 +9526,14 @@ resolve_symbol (gfc_symbol *sym)
if ((isym = gfc_find_function (sym->name)))
{
- if (sym->ts.type != BT_UNKNOWN && gfc_option.warn_surprising)
+ if (sym->ts.type != BT_UNKNOWN && gfc_option.warn_surprising
+ && !sym->attr.implicit_type)
gfc_warning ("Type specified for intrinsic function '%s' at %L is"
" ignored", sym->name, &sym->declared_at);
}
else if ((isym = gfc_find_subroutine (sym->name)))
{
- if (sym->ts.type != BT_UNKNOWN)
+ if (sym->ts.type != BT_UNKNOWN && !sym->attr.implicit_type)
{
gfc_error ("Intrinsic subroutine '%s' at %L shall not have a type"
" specifier", sym->name, &sym->declared_at);
Index: gcc/testsuite/gfortran.dg/intrinsic_2.f90
===================================================================
--- gcc/testsuite/gfortran.dg/intrinsic_2.f90 (revision 0)
+++ gcc/testsuite/gfortran.dg/intrinsic_2.f90 (revision 0)
@@ -0,0 +1,40 @@
+! { dg-do compile }
+! { dg-options "-c -Wall" }
+!
+! PR fortran/40041
+! cf. also PR fortran/20373
+
+subroutine valid_one
+ REAL :: a
+ INTEGER :: n
+ INTRINSIC ABS, MAX
+ a(n) = MAX(ABS(2),ABS(3),n)
+end subroutine
+
+subroutine valid_two
+ IMPLICIT NONE
+ REAL :: a
+ INTEGER :: n
+ INTRINSIC ABS, MAX
+ a(n) = MAX(ABS(2),ABS(3),n)
+end subroutine
+
+subroutine warnings_one
+ REAL :: a
+ INTEGER :: n
+ REAL :: ABS ! { dg-warning "Type specified for intrinsic function" }
+ REAL :: MAX ! { dg-warning "Type specified for intrinsic function" }
+ INTRINSIC ABS, MAX
+ a(n) = MAX(ABS(2),ABS(3),n)
+end subroutine
+
+subroutine warnings_two
+ IMPLICIT NONE
+ REAL :: a
+ INTEGER :: n
+ INTRINSIC ABS ! { dg-warning "Type specified for intrinsic function" }
+ INTRINSIC MAX ! { dg-warning "Type specified for intrinsic function" }
+ REAL :: ABS
+ REAL :: MAX
+ a(n) = MAX(ABS(2),ABS(3),n)
+end subroutine
Index: gcc/testsuite/gfortran.dg/intrinsic.f90
===================================================================
--- gcc/testsuite/gfortran.dg/intrinsic.f90 (revision 147171)
+++ gcc/testsuite/gfortran.dg/intrinsic.f90 (working copy)
@@ -1,5 +1,8 @@
! { dg-do compile }
! { dg-options "-c -Wall" }
+!
+! PR fortran/20373
+! cf. also PR fortran/40041
subroutine valid
intrinsic :: abs ! ok, intrinsic function