View | Details | Return to bug 29975 | Differences between
and this patch

Collapse All | Expand All

(-)gcc/fortran/symbol.c (-3 / +7 lines)
Lines 1996-2002 Link Here
1996
      if (st != NULL)
1996
      if (st != NULL)
1997
	{
1997
	{
1998
	  *result = st;
1998
	  *result = st;
1999
	  if (st->ambiguous)
1999
	  /* Ambiguous generic interfaces are permitted, as long
2000
	     as the specific interfaces are different.  */
2001
	  if (st->ambiguous && !st->n.sym->attr.generic)
2000
	    {
2002
	    {
2001
	      ambiguous_symbol (name, st);
2003
	      ambiguous_symbol (name, st);
2002
	      return 1;
2004
	      return 1;
Lines 2097-2104 Link Here
2097
    }
2099
    }
2098
  else
2100
  else
2099
    {
2101
    {
2100
      /* Make sure the existing symbol is OK.  */
2102
      /* Make sure the existing symbol is OK.  Ambiguous
2101
      if (st->ambiguous)
2103
	 generic interfaces are permitted, as long as the
2104
	 specific interfaces are different.  */
2105
      if (st->ambiguous && !st->n.sym->attr.generic)
2102
	{
2106
	{
2103
	  ambiguous_symbol (name, st);
2107
	  ambiguous_symbol (name, st);
2104
	  return 1;
2108
	  return 1;
(-)gcc/testsuite/gfortran.dg/interface_x.f90 (+46 lines)
Line 0 Link Here
1
! { dg-do run }
2
! Tests the fix for the interface bit of PR29975, in which the
3
! interfaces bl_copy were rejected as ambiguous, even though
4
! they import different specific interfaces.
5
!
6
! Contributed by Joost VandeVondele <jv244@cam.ac.uk> and
7
! simplified by Tobias Burnus <burnus@gcc.gnu.org>
8
!
9
SUBROUTINE RECOPY(N, c)
10
  real, INTENT(IN) :: N
11
  character(6) :: c
12
  c = "recopy"
13
END SUBROUTINE RECOPY
14
15
MODULE f77_blas_extra
16
PUBLIC :: BL_COPY
17
INTERFACE BL_COPY
18
  MODULE PROCEDURE SDCOPY
19
END INTERFACE BL_COPY
20
CONTAINS
21
   SUBROUTINE SDCOPY(N, c)
22
    INTEGER, INTENT(IN) :: N
23
    character(6) :: c
24
    c = "sdcopy"
25
   END SUBROUTINE SDCOPY
26
END MODULE f77_blas_extra
27
28
MODULE f77_blas_generic
29
INTERFACE BL_COPY
30
   SUBROUTINE RECOPY(N, c)
31
    real, INTENT(IN) :: N
32
    character(6) :: c
33
   END SUBROUTINE RECOPY
34
END INTERFACE BL_COPY
35
END MODULE f77_blas_generic
36
37
program main
38
  USE f77_blas_extra
39
  USE f77_blas_generic
40
  character(6) :: chr
41
  call bl_copy(1, chr)
42
  if (chr /= "sdcopy") call abort ()
43
  call bl_copy(1.0, chr)
44
  if (chr /= "recopy") call abort ()  
45
end program main
46
! { dg-final { cleanup-modules "f77_blas_generic f77_blas_extra" } }
(-)gcc/testsuite/gfortran.dg/interface_y.f90 (+45 lines)
Line 0 Link Here
1
! { dg-do compile }
2
! Tests the fix for the interface bit of PR29975, in which the
3
! interfaces bl_copy were rejected as ambiguous, even though
4
! they import different specific interfaces.  In this testcase,
5
! it is verified that ambiguous specific interfaces are caught.
6
!
7
! Contributed by Joost VandeVondele <jv244@cam.ac.uk> and
8
! simplified by Tobias Burnus <burnus@gcc.gnu.org>
9
!
10
SUBROUTINE RECOPY(N, c)
11
  real, INTENT(IN) :: N
12
  character(6) :: c
13
  c = "recopy"
14
END SUBROUTINE RECOPY
15
16
MODULE f77_blas_extra
17
PUBLIC :: BL_COPY
18
INTERFACE BL_COPY
19
  MODULE PROCEDURE SDCOPY
20
END INTERFACE BL_COPY
21
CONTAINS
22
   SUBROUTINE SDCOPY(N, c)
23
    REAL, INTENT(IN) :: N
24
    character(6) :: c
25
    c = "sdcopy"
26
   END SUBROUTINE SDCOPY
27
END MODULE f77_blas_extra
28
29
MODULE f77_blas_generic
30
INTERFACE BL_COPY
31
   SUBROUTINE RECOPY(N, c)
32
    real, INTENT(IN) :: N
33
    character(6) :: c
34
   END SUBROUTINE RECOPY
35
END INTERFACE BL_COPY
36
END MODULE f77_blas_generic
37
38
program main
39
  USE f77_blas_extra ! { dg-error "Ambiguous|interfaces" }
40
  USE f77_blas_generic
41
  character(6) :: chr
42
  call bl_copy(1.0, chr)
43
  if (chr /= "recopy") call abort ()  
44
end program main
45
! { dg-final { cleanup-modules "f77_blas_generic f77_blas_extra" } }

Return to bug 29975