the given interface list. Ambiguity isn't checked yet since module
procedures can be present without interfaces. */
-static gfc_try
-check_new_interface (gfc_interface *base, gfc_symbol *new_sym)
+gfc_try
+gfc_check_new_interface (gfc_interface *base, gfc_symbol *new_sym, locus loc)
{
gfc_interface *ip;
{
if (ip->sym == new_sym)
{
- gfc_error ("Entity '%s' at %C is already present in the interface",
- new_sym->name);
+ gfc_error ("Entity '%s' at %L is already present in the interface",
+ new_sym->name, &loc);
return FAILURE;
}
}
{
case INTRINSIC_EQ:
case INTRINSIC_EQ_OS:
- if (check_new_interface (ns->op[INTRINSIC_EQ], new_sym) == FAILURE ||
- check_new_interface (ns->op[INTRINSIC_EQ_OS], new_sym) == FAILURE)
+ if (gfc_check_new_interface (ns->op[INTRINSIC_EQ], new_sym,
+ gfc_current_locus) == FAILURE
+ || gfc_check_new_interface (ns->op[INTRINSIC_EQ_OS], new_sym,
+ gfc_current_locus) == FAILURE)
return FAILURE;
break;
case INTRINSIC_NE:
case INTRINSIC_NE_OS:
- if (check_new_interface (ns->op[INTRINSIC_NE], new_sym) == FAILURE ||
- check_new_interface (ns->op[INTRINSIC_NE_OS], new_sym) == FAILURE)
+ if (gfc_check_new_interface (ns->op[INTRINSIC_NE], new_sym,
+ gfc_current_locus) == FAILURE
+ || gfc_check_new_interface (ns->op[INTRINSIC_NE_OS], new_sym,
+ gfc_current_locus) == FAILURE)
return FAILURE;
break;
case INTRINSIC_GT:
case INTRINSIC_GT_OS:
- if (check_new_interface (ns->op[INTRINSIC_GT], new_sym) == FAILURE ||
- check_new_interface (ns->op[INTRINSIC_GT_OS], new_sym) == FAILURE)
+ if (gfc_check_new_interface (ns->op[INTRINSIC_GT], new_sym,
+ gfc_current_locus) == FAILURE
+ || gfc_check_new_interface (ns->op[INTRINSIC_GT_OS], new_sym,
+ gfc_current_locus) == FAILURE)
return FAILURE;
break;
case INTRINSIC_GE:
case INTRINSIC_GE_OS:
- if (check_new_interface (ns->op[INTRINSIC_GE], new_sym) == FAILURE ||
- check_new_interface (ns->op[INTRINSIC_GE_OS], new_sym) == FAILURE)
+ if (gfc_check_new_interface (ns->op[INTRINSIC_GE], new_sym,
+ gfc_current_locus) == FAILURE
+ || gfc_check_new_interface (ns->op[INTRINSIC_GE_OS], new_sym,
+ gfc_current_locus) == FAILURE)
return FAILURE;
break;
case INTRINSIC_LT:
case INTRINSIC_LT_OS:
- if (check_new_interface (ns->op[INTRINSIC_LT], new_sym) == FAILURE ||
- check_new_interface (ns->op[INTRINSIC_LT_OS], new_sym) == FAILURE)
+ if (gfc_check_new_interface (ns->op[INTRINSIC_LT], new_sym,
+ gfc_current_locus) == FAILURE
+ || gfc_check_new_interface (ns->op[INTRINSIC_LT_OS], new_sym,
+ gfc_current_locus) == FAILURE)
return FAILURE;
break;
case INTRINSIC_LE:
case INTRINSIC_LE_OS:
- if (check_new_interface (ns->op[INTRINSIC_LE], new_sym) == FAILURE ||
- check_new_interface (ns->op[INTRINSIC_LE_OS], new_sym) == FAILURE)
+ if (gfc_check_new_interface (ns->op[INTRINSIC_LE], new_sym,
+ gfc_current_locus) == FAILURE
+ || gfc_check_new_interface (ns->op[INTRINSIC_LE_OS], new_sym,
+ gfc_current_locus) == FAILURE)
return FAILURE;
break;
default:
- if (check_new_interface (ns->op[current_interface.op], new_sym) == FAILURE)
+ if (gfc_check_new_interface (ns->op[current_interface.op], new_sym,
+ gfc_current_locus) == FAILURE)
return FAILURE;
}
if (sym == NULL)
continue;
- if (check_new_interface (sym->generic, new_sym) == FAILURE)
+ if (gfc_check_new_interface (sym->generic, new_sym, gfc_current_locus)
+ == FAILURE)
return FAILURE;
}
break;
case INTERFACE_USER_OP:
- if (check_new_interface (current_interface.uop->op, new_sym)
- == FAILURE)
+ if (gfc_check_new_interface (current_interface.uop->op, new_sym,
+ gfc_current_locus) == FAILURE)
return FAILURE;
head = ¤t_interface.uop->op;
--- /dev/null
+! { dg-do compile }
+!
+! PR 49591: [OOP] Multiple identical specific procedures in type-bound operator not detected
+!
+! This is interpretation request F03/0018:
+! http://www.j3-fortran.org/doc/meeting/195/11-214.txt
+!
+! Contributed by Tobias Burnus <burnus@gcc.gnu.org>
+
+module M1
+ type T
+ integer x
+ contains
+ procedure :: MyAdd_t => myadd
+ generic :: operator(+) => myAdd_t
+ end type T
+ type X
+ real q
+ contains
+ procedure, pass(b) :: MyAdd_x => myadd
+ generic :: operator(+) => myAdd_x ! { dg-error "is already present in the interface" }
+ end type X
+contains
+ integer function MyAdd ( A, B )
+ class(t), intent(in) :: A
+ class(x), intent(in) :: B
+ myadd = a%x + b%q
+ end function MyAdd
+end module
+
+module M2
+ interface operator(+)
+ procedure MyAdd
+ end interface
+ type T
+ integer x
+ contains
+ procedure :: MyAdd_t => myadd
+ generic :: operator(+) => myAdd_t ! { dg-error "is already present in the interface" }
+ end type T
+contains
+ integer function MyAdd ( A, B )
+ class(t), intent(in) :: A
+ real, intent(in) :: B
+ myadd = a%x + b
+ end function MyAdd
+end module
+
+! { dg-final { cleanup-modules "M1 M2" } }