GENERIC type-bound procedures are currently implemented in gfortran, but only by name and not as operators as in the following example (the polymorphic passed-object problem included): MODULE m IMPLICIT NONE TYPE :: t INTEGER :: i CONTAINS PROCEDURE :: assign_t_from_int PROCEDURE :: equals_t_int GENERIC :: ASSIGNMENT(=) => assign_t_from_int GENERIC :: OPERATOR(==) => equals_t_int END TYPE t CONTAINS SUBROUTINE assign_t_from_int (me, i) IMPLICIT NONE TYPE(t), INTENT(OUT) :: me INTEGER, INTENT(IN) :: i me = t (i) END SUBROUTINE assign_t_from_int LOGICAL FUNCTION equals_t_int (me, i) IMPLICIT NONE TYPE(t) :: me INTEGER :: i equals_t_int = (me%i == i) END FUNCTION equals_t_int END MODULE m
Subject: Bug 37425 Author: domob Date: Mon Aug 10 10:51:46 2009 New Revision: 150622 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=150622 Log: 2009-08-10 Daniel Kraft <d@domob.eu> PR fortran/37425 * gfortran.dg/typebound_operator_1.f03: New test. * gfortran.dg/typebound_operator_2.f03: New test. 2009-08-10 Daniel Kraft <d@domob.eu> PR fortran/37425 * gfortran.h (struct gfc_namespace): New fields tb_uop_root and tb_op. (gfc_find_typebound_user_op): New routine. (gfc_find_typebound_intrinsic_op): Ditto. (gfc_check_operator_interface): Now public routine. * decl.c (gfc_match_generic): Match OPERATOR(X) or ASSIGNMENT(=). * interface.c (check_operator_interface): Made public, renamed to `gfc_check_operator_interface' accordingly and hand in the interface as gfc_symbol rather than gfc_interface so it is useful for type-bound operators, too. Return boolean result. (gfc_check_interfaces): Adapt call to `check_operator_interface'. * symbol.c (gfc_get_namespace): Initialize new field `tb_op'. (gfc_free_namespace): Free `tb_uop_root'-based tree. (find_typebound_proc_uop): New helper function. (gfc_find_typebound_proc): Use it. (gfc_find_typebound_user_op): New method. (gfc_find_typebound_intrinsic_op): Ditto. * resolve.c (resolve_tb_generic_targets): New helper function. (resolve_typebound_generic): Use it. (resolve_typebound_intrinsic_op), (resolve_typebound_user_op): New. (resolve_typebound_procedures): Resolve operators, too. (check_uop_procedure): New, code from gfc_resolve_uops. (gfc_resolve_uops): Moved main code to new `check_uop_procedure'. Added: trunk/gcc/testsuite/gfortran.dg/typebound_operator_1.f03 trunk/gcc/testsuite/gfortran.dg/typebound_operator_2.f03 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/decl.c trunk/gcc/fortran/gfortran.h trunk/gcc/fortran/interface.c trunk/gcc/fortran/resolve.c trunk/gcc/fortran/symbol.c trunk/gcc/testsuite/ChangeLog
After the check-in now, type-bound operators are parsed/checked correctly, but can not be called for now. I'll work on that as a follow-up patch. This means that the test-case given in the report works, but of course I'll keep the PR open until type-bound operators are fully supported.
Subject: Bug 37425 Author: domob Date: Mon Aug 17 18:55:30 2009 New Revision: 150856 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=150856 Log: 2009-08-17 Daniel Kraft <d@domob.eu> PR fortran/37425 * resolve.c (get_checked_tb_operator_target): New routine to do checks on type-bound operators in common between intrinsic and user operators. (resolve_typebound_intrinsic_op): Call it. (resolve_typebound_user_op): Ditto. 2009-08-17 Daniel Kraft <d@domob.eu> PR fortran/37425 * gfortran.dg/typebound_operator_2.f03: Test for error with illegal NOPASS bindings as operators. Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/resolve.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gfortran.dg/typebound_operator_2.f03
Subject: Bug 37425 Author: domob Date: Thu Aug 27 11:42:56 2009 New Revision: 151140 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=151140 Log: 2009-08-27 Daniel Kraft <d@domob.eu> PR fortran/37425 * gfortran.h (gfc_expr): Optionally store base-object in compcall value and add a new flag to distinguish assign-calls generated. (gfc_find_typebound_proc): Add locus argument. (gfc_find_typebound_user_op), (gfc_find_typebound_intrinsic_op): Ditto. (gfc_extend_expr): Return if failure was by a real error. * interface.c (matching_typebound_op): New routine. (build_compcall_for_operator): New routine. (gfc_extend_expr): Handle type-bound operators, some clean-up and return if failure was by a real error or just by not finding an appropriate operator definition. (gfc_extend_assign): Handle type-bound assignments. * module.c (MOD_VERSION): Incremented. (mio_intrinsic_op): New routine. (mio_full_typebound_tree): New routine to make typebound-procedures IO code reusable for type-bound user operators. (mio_f2k_derived): IO of type-bound operators. * primary.c (gfc_match_varspec): Initialize new fields in gfc_expr and pass locus to gfc_find_typebound_proc. * resolve.c (resolve_operator): Only output error about no matching interface if gfc_extend_expr did not already fail with an error. (extract_compcall_passed_object): Use specified base-object if present. (update_compcall_arglist): Handle ignore_pass field. (resolve_ordinary_assign): Update to handle extended code for type-bound assignments, too. (resolve_code): Handle EXEC_ASSIGN_CALL statement code. (resolve_tb_generic_targets): Pass locus to gfc_find_typebound_proc. (resolve_typebound_generic), (resolve_typebound_procedure): Ditto. (resolve_typebound_intrinsic_op), (resolve_typebound_user_op): Ditto. (ensure_not_abstract_walker), (resolve_fl_derived): Ditto. (resolve_typebound_procedures): Remove not-implemented error. (resolve_typebound_call): Handle assign-call flag. * symbol.c (find_typebound_proc_uop): New argument to pass locus for error message about PRIVATE, verify that a found procedure is not marked as erraneous. (gfc_find_typebound_intrinsic_op): Ditto. (gfc_find_typebound_proc), (gfc_find_typebound_user_op): New locus arg. 2009-08-27 Daniel Kraft <d@domob.eu> PR fortran/37425 * gfortran.dg/impure_assignment_1.f90: Change expected error message. * gfortran.dg/typebound_operator_1.f03: Remove check for not-implemented error and fix problem with recursive assignment. * gfortran.dg/typebound_operator_2.f03: No not-implemented check. * gfortran.dg/typebound_operator_3.f03: New test. * gfortran.dg/typebound_operator_4.f03: New test. Added: trunk/gcc/testsuite/gfortran.dg/typebound_operator_3.f03 trunk/gcc/testsuite/gfortran.dg/typebound_operator_4.f03 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/gfortran.h trunk/gcc/fortran/interface.c trunk/gcc/fortran/module.c trunk/gcc/fortran/primary.c trunk/gcc/fortran/resolve.c trunk/gcc/fortran/symbol.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gfortran.dg/impure_assignment_1.f90 trunk/gcc/testsuite/gfortran.dg/typebound_operator_1.f03 trunk/gcc/testsuite/gfortran.dg/typebound_operator_2.f03
Subject: Bug 37425 Author: domob Date: Sun Aug 30 08:26:38 2009 New Revision: 151224 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=151224 Log: 2009-08-30 Daniel Kraft <d@domob.eu> PR fortran/37425 * dump-parse-tree.c (show_typebound_proc): Renamed from `show_typebound' and accept gfc_typebound_proc and name instead of the symtree, needed for intrinsic operator output. (show_typebound_symtree): New method calling `show_typebound_proc'. (show_f2k_derived): Output type-bound operators also. (show_symbol): Moved output of `Procedure bindings:' label to `show_f2k_derived'. * gfortran.texi (Fortran 2003 status): Mention support of array-constructors with explicit type specification, type-bound procedures/operators, type extension, ABSTRACT types and DEFERRED. Link to Fortran 2003 wiki page. (Fortran 2008 status): Fix typo. Link to Fortran 2008 wiki page. * gfc-internals.texi (Type-bound Procedures): Document the new members/attributes of gfc_expr.value.compcall used for type-bound operators. (Type-bound Operators): New section documenting their internals. Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/dump-parse-tree.c trunk/gcc/fortran/gfc-internals.texi trunk/gcc/fortran/gfortran.texi
This is fully implemented now (except some side-issues which have their own PRs, like PR 41177 and PR 41178), closing.