Code: SUBROUTINE BUG(WORK) DOUBLE PRECISION WORK(MAX(2,3)) INTRINSIC MAX END Compile: >gfortran -fimplicit-none -c foo.f foo.f:4.72: END 1 Error: Symbol 'a1' at (1) has no IMPLICIT type foo.f:4.72: END 1 Error: Symbol 'a2' at (1) has no IMPLICIT type ________________________________________________________________ nonsensical error when there shouldn't be one? Regards Themos Tsikas
Please post result of gfortran -v
I do not see the problem with gfortran 4.3.4 on Cygwin
Confirmed on x86_64-apple-darwin10.3.0 for 4.5.0 and trunk, but not 4.4.4, hence it is a regression.
As you might have guessed, the error is with regards to the arguments of MAX which are A1 and A2. The arguments are defined as BT_UNKNOWN, cf. in intrinsics.c: add_sym_1m ("max", GFC_ISYM_MAX, CLASS_ELEMENTAL, ACTUAL_NO, BT_UNKNOWN, 0, GFC_STD_F77, gfc_check_min_max, gfc_simplify_max, gfc_resolve_max, a1, BT_UNKNOWN, dr, REQUIRED, a2, BT_UNKNOWN, dr, REQUIRED); The backtrace shows: #0 gfc_set_default_type (sym=0x144e6b0, error_flag=1, ns=<value optimized out>) at fortran/symbol.c:263 #1 0x00000000005328d7 in resolve_formal_arglist (proc=0x144d1f0) at fortran/resolve.c:303
The following (pretty obvious) patch fixes it: Index: gcc/fortran/resolve.c =================================================================== --- gcc/fortran/resolve.c (revision 164899) +++ gcc/fortran/resolve.c (working copy) @@ -297,11 +297,9 @@ resolve_formal_arglist (gfc_symbol *proc) continue; } - if (sym->ts.type == BT_UNKNOWN) - { - if (!sym->attr.function || sym->result == sym) - gfc_set_default_type (sym, 1, sym->ns); - } + if (sym->ts.type == BT_UNKNOWN && !proc->attr.intrinsic + && (!sym->attr.function || sym->result == sym)) + gfc_set_default_type (sym, 1, sym->ns); gfc_resolve_array_spec (sym->as, 0);
Author: janus Date: Sat Oct 2 10:38:42 2010 New Revision: 164901 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=164901 Log: 2010-10-02 Janus Weil <janus@gcc.gnu.org> PR fortran/45748 * resolve.c (resolve_formal_arglist): Avoid setting default type for formal arguments of intrinsic procedures. 2010-10-02 Janus Weil <janus@gcc.gnu.org> PR fortran/45748 * gfortran.dg/intrinsic_6.f90: New. Added: trunk/gcc/testsuite/gfortran.dg/intrinsic_6.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/resolve.c trunk/gcc/testsuite/ChangeLog
Author: janus Date: Sat Oct 9 13:41:12 2010 New Revision: 165223 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=165223 Log: 2010-10-09 Janus Weil <janus@gcc.gnu.org> PR fortran/45748 * resolve.c (resolve_formal_arglist): Avoid setting default type for formal arguments of intrinsic procedures. 2010-10-09 Janus Weil <janus@gcc.gnu.org> PR fortran/45748 * gfortran.dg/intrinsic_6.f90: New. Added: branches/gcc-4_5-branch/gcc/testsuite/gfortran.dg/intrinsic_6.f90 Modified: branches/gcc-4_5-branch/gcc/fortran/ChangeLog branches/gcc-4_5-branch/gcc/fortran/resolve.c branches/gcc-4_5-branch/gcc/testsuite/ChangeLog
Fixed on trunk and 4.5. Closing.