From patchwork Fri Mar 2 09:35:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [Fortran] PR52452 [4.5-4.7 Regr.] Intrinsic wrongly rejected Date: Thu, 01 Mar 2012 23:35:02 -0000 From: Tobias Burnus X-Patchwork-Id: 144167 Message-Id: <4F509446.3010007@net-b.de> To: gcc patches , gfortran There is a 4.5 to 4.7 regression for those (vendor) intrinsic procedures, which can exists as both subroutine and as function. Example: INTRINSIC :: etime CALL etime(tarray, result) Here, the "etime" gets marked as attr.subroutine, but later in resolve_intrinsics, it is mapped to the intrinsic function "etime". But then the compiler complains: Error: FUNCTION attribute conflicts with SUBROUTINE attribute in 'etime' at (1) Solution: Don't search for the function, if we have a subroutine. (For some reasons, it works without "INTRINSIC :: etime".) Build and regtested on x86-64-linux. OK for the trunk - and the 4.5 to 4.6 branches? Tobias PS: I will ask for RM approval if this patch gets approved after (today's?) RC1 release. 2012-03-02 Tobias Burnus PR fortran/52452 * resolve.c (resolve_intrinsic): Don't search for a function if we know that it is a subroutine. 2012-03-02 Tobias Burnus PR fortran/52452 * gfortran.dg/intrinsic_8.f90: New. diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 4dcf9b1..049a926 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -1496,7 +1498,7 @@ resolve_intrinsic (gfc_symbol *sym, locus *loc) if (sym->intmod_sym_id) isym = gfc_intrinsic_function_by_id ((gfc_isym_id) sym->intmod_sym_id); - else + else if (!sym->attr.subroutine) isym = gfc_find_function (sym->name); if (isym) --- /dev/null 2012-03-02 07:37:33.883806634 +0100 +++ gcc/gcc/testsuite/gfortran.dg/intrinsic_8.f90 2012-03-02 08:59:51.000000000 +0100 @@ -0,0 +1,23 @@ +! { dg-do compile } +! +! PR fortran/52452 +! +! Contributed by Roger Ferrer Ibanez +! +PROGRAM test_etime + IMPLICIT NONE + INTRINSIC :: etime + REAL(4) :: tarray(1:2) + REAL(4) :: result + + CALL etime(tarray, result) +END PROGRAM test_etime + +subroutine test_etime2 + IMPLICIT NONE + INTRINSIC :: etime + REAL(4) :: tarray(1:2) + REAL(4) :: result + + result = etime(tarray) +END subroutine test_etime2