using GNU Fortran 95 (GCC) 4.1.0 20051126 (prerelease) with '-g -pedantic -std=f95', I get a bad / no diagnostic for the following invalid code: MODULE M1 CONTAINS FUNCTION L() L=1 END FUNCTION L PURE FUNCTION J(K) INTERFACE PURE FUNCTION K() END FUNCTION K END INTERFACE J=K() END FUNCTION J END MODULE M1 USE M1 write(6,*) J(L) END
gfortran doesn't catch this one. ## g95 ## In file foo.f90:15 write(6,*) J(L) 1 Error: Dummy procedure 'l' at (1) must be PURE ## Intel ## fortcom: Warning: foo.f90, line 3: This name has not been given an explicit type. [L] FUNCTION L() ----------^ fortcom: Warning: foo.f90, line 8: This name has not been given an explicit type. [K] PURE FUNCTION K() -------------------^ fortcom: Warning: foo.f90, line 6: This name has not been given an explicit type. [J] PURE FUNCTION J(K) ---------------^ fortcom: Error: foo.f90, line 15: Procedure argument must be PURE [L] write(6,*) J(L) --------------^ fortcom: Error: foo.f90, line 15: The PURE attribute of the associated actual procedure differs from the PURE attribute of the dummy procedure. [L] write(6,*) J(L) --------------^ compilation aborted for foo.f90 (code 1) ## Portland ## ## Sun ## write(6,*) J(L) ^ "foo.f90", Line = 15, Column = 15: ERROR: Procedure "K" is being passed to PURE procedure "L". It must also be PURE.
Created attachment 11727 [details] Patch to fix the PR A straightforward check in interface.c (compare_actual_formal) was all that was required. Paul
Subject: Bug 25056 Author: pault Date: Sun Jun 25 15:11:02 2006 New Revision: 114987 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114987 Log: 2006-06-25 Paul Thomas <pault@gcc.gnu.org> PR fortran/25056 * interface.c (compare_actual_formal): Signal an error if the formal argument is a pure procedure and the actual is not pure. PR fortran/27554 * resolve.c (resolve_actual_arglist): If the type of procedure passed as an actual argument is not already declared, see if it is an intrinsic. PR fortran/25073 * resolve.c (resolve_select): Use bits 1 and 2 of a new int to keep track of the appearance of constant logical case expressions. Signal an error is either value appears more than once. PR fortran/20874 * resolve.c (resolve_fl_procedure): Signal an error if an elemental function is not scalar valued. PR fortran/20867 * match.c (recursive_stmt_fcn): Perform implicit typing of variables. PR fortran/22038 * match.c (match_forall_iterator): Mark new variables as FL_UNKNOWN if the match fails. PR fortran/28119 * match.c (gfc_match_forall): Remove extraneous call to gfc_match_eos. PR fortran/25072 * resolve.c (resolve_code, resolve_function): Rework forall_flag scheme so that it is set and has a value of 2, when the code->expr (ie. the forall mask) is resolved. This is used to change "block" to "mask" in the non-PURE error message. 2006-06-25 Paul Thomas <pault@gcc.gnu.org> PR fortran/20867 * gfortran.dg/stfunc_3.f90: New test. PR fortran/25056 * gfortran.dg/impure_actual_1.f90: New test. PR fortran/20874 * gfortran.dg/elemental_result_1.f90: New test. PR fortran/25073 * gfortran.dg/select_7.f90: New test. PR fortran/27554 * intrinsic_actual_1.f: New test. PR fortran/22038 PR fortran/28119 * gfortran.dg/forall_4.f90: New test. PR fortran/25072 * gfortran.dg/forall_5.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/elemental_result_1.f90 trunk/gcc/testsuite/gfortran.dg/forall_4.f90 trunk/gcc/testsuite/gfortran.dg/forall_5.f90 trunk/gcc/testsuite/gfortran.dg/impure_actual_1.f90 trunk/gcc/testsuite/gfortran.dg/intrinsic_actual_1.f trunk/gcc/testsuite/gfortran.dg/select_7.f90 trunk/gcc/testsuite/gfortran.dg/stfunc_3.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/interface.c trunk/gcc/fortran/match.c trunk/gcc/fortran/resolve.c trunk/gcc/testsuite/ChangeLog
Subject: Bug 25056 Author: pault Date: Sun Jun 25 18:08:13 2006 New Revision: 114994 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114994 Log: 2006-06-25 Paul Thomas <pault@gcc.gnu.org> PR fortran/25056 * interface.c (compare_actual_formal): Signal an error if the formal argument is a pure procedure and the actual is not pure. PR fortran/27554 * resolve.c (resolve_actual_arglist): If the type of procedure passed as an actual argument is not already declared, see if it is an intrinsic. PR fortran/25073 * resolve.c (resolve_select): Use bits 1 and 2 of a new int to keep track of the appearance of constant logical case expressions. Signal an error is either value appears more than once. PR fortran/20874 * resolve.c (resolve_fl_procedure): Signal an error if an elemental function is not scalar valued. PR fortran/20867 * match.c (recursive_stmt_fcn): Perform implicit typing of variables. PR fortran/22038 * match.c (match_forall_iterator): Mark new variables as FL_UNKNOWN if the match fails. PR fortran/28119 * match.c (gfc_match_forall): Remove extraneous call to gfc_match_eos. PR fortran/25072 * resolve.c (resolve_code, resolve_function): Rework forall_flag scheme so that it is set and has a value of 2, when the code->expr (ie. the forall mask) is resolved. This is used to change "block" to "mask" in the non-PURE error message. 2006-06-25 Paul Thomas <pault@gcc.gnu.org> PR fortran/20867 * gfortran.dg/stfunc_3.f90: New test. PR fortran/25056 * gfortran.dg/impure_actual_1.f90: New test. PR fortran/20874 * gfortran.dg/elemental_result_1.f90: New test. PR fortran/25073 * gfortran.dg/select_7.f90: New test. PR fortran/27554 * intrinsic_actual_1.f: New test. PR fortran/22038 PR fortran/28119 * gfortran.dg/forall_4.f90: New test. PR fortran/25072 * gfortran.dg/forall_5.f90: New test. Added: branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/elemental_result_1.f90 branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/forall_4.f90 branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/forall_5.f90 branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/impure_actual_1.f90 branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/intrinsic_actual_1.f branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/select_7.f90 branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/stfunc_3.f90 Modified: branches/gcc-4_1-branch/gcc/fortran/ChangeLog branches/gcc-4_1-branch/gcc/fortran/interface.c branches/gcc-4_1-branch/gcc/fortran/match.c branches/gcc-4_1-branch/gcc/fortran/resolve.c branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
Fixed on trunk and 4.1 Paul