[Bug fortran/52024] [OOP] GENERIC operator cannot be resolved
burnus at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sat Jan 28 15:12:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52024
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|unassigned at gcc dot |burnus at gcc dot gnu.org
|gnu.org |
--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-01-28 12:38:56 UTC ---
(In reply to comment #3)
> The question is only: What does that "generic_flag" actually do?
Answer: For generic procedures which are not operators one can do:
generic (i=4, t=x)
which matches both interfaces:
function t_equal_i( t, i ) result(res)
function i_equal_t( i, t ) result(res)
For operators, the "t=" syntax is not possible, the argument order is fixed
and, thus, for operators the interface is not ambiguous.
Untested patch:
Index: gfortran.h
===================================================================
--- gfortran.h (Revision 183664)
+++ gfortran.h
@@ -1118,2 +1118,3 @@ typedef struct gfc_tbp_generic
struct gfc_tbp_generic* next;
+ bool is_operator;
}
Index: resolve.c
===================================================================
--- resolve.c (Revision 183664)
+++ resolve.c
@@ -10966,2 +10995,3 @@ check_generic_tbp_ambiguity (gfc_tbp_gen
gcc_assert (!t2->specific->is_generic);
+ gcc_assert (t1->is_operator == t2->is_operator);
@@ -10984,3 +11014,4 @@ check_generic_tbp_ambiguity (gfc_tbp_gen
/* Compare the interfaces. */
- if (gfc_compare_interfaces (sym1, sym2, sym2->name, 1, 0, NULL, 0))
+ if (gfc_compare_interfaces (sym1, sym2, sym2->name, !t1->is_operator, 0,
+ NULL, 0))
{
Index: decl.c
===================================================================
--- decl.c (Revision 183664)
+++ decl.c
@@ -8394,2 +8394,4 @@ gfc_match_generic (void)
target->next = tb->u.generic;
+ target->is_operator = ((op_type == INTERFACE_USER_OP)
+ || (op_type == INTERFACE_INTRINSIC_OP));
tb->u.generic = target;
More information about the Gcc-bugs
mailing list