]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/29652 (ambiguous interface declaration undetected)
authorPaul Thomas <pault@gcc.gnu.org>
Wed, 22 Nov 2006 00:02:02 +0000 (00:02 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Wed, 22 Nov 2006 00:02:02 +0000 (00:02 +0000)
2006-11-22 Paul Thomas  <pault@gcc.gnu.org>

PR fortran/29652
* interface.c (check_interface1): Use a local value, instead of
the dummy, as the inner iterator over interface symbols.

2006-11-22 Paul Thomas  <pault@gcc.gnu.org>

PR fortran/29652
* gfortran.dg/generic_7.f90: New test.
* gfortran.dg/defined_operators_1.f90: Add new error.

From-SVN: r119076

gcc/fortran/ChangeLog
gcc/fortran/interface.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/defined_operators_1.f90
gcc/testsuite/gfortran.dg/generic_7.f90 [new file with mode: 0644]

index bfc6d6db223c8fb8fc9ffe647b0515c812a13634..d758a484db439b5397df4b7cbfd7005fdc209444 100644 (file)
@@ -1,3 +1,9 @@
+2006-11-22 Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/29652
+       * interface.c (check_interface1): Use a local value, instead of
+       the dummy, as the inner iterator over interface symbols.
+
 2006-11-21 Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/29820
index 5a9b2da7064defaf5d8a1a4fddc30a7f6edc077d..e1564b21e2ee6faaec9474d4c4c22b40e79cc820 100644 (file)
@@ -964,12 +964,12 @@ check_interface0 (gfc_interface * p, const char *interface_name)
    here.  */
 
 static int
-check_interface1 (gfc_interface * p, gfc_interface * q,
+check_interface1 (gfc_interface * p, gfc_interface * q0,
                  int generic_flag, const char *interface_name)
 {
-
+  gfc_interface * q;
   for (; p; p = p->next)
-    for (; q; q = q->next)
+    for (q = q0; q; q = q->next)
       {
        if (p->sym == q->sym)
          continue;             /* Duplicates OK here */
index 58ed09da58be03ccb8a5813500f641cfa9201242..564af554773178814ef9d251e630e25dc3ebc9b0 100644 (file)
@@ -1,3 +1,9 @@
+2006-11-22 Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/29652
+       * gfortran.dg/generic_7.f90: New test.
+       * gfortran.dg/defined_operators_1.f90: Add new error.
+
 2006-11-22  Zdenek Dvorak <dvorakz@suse.cz>
 
        PR tree-optimization/29902
index c2369b2317c1239dd3f99a694e2cb59787947b82..0233bf0b9a743504d4ec51484015f59caa4e2102 100644 (file)
@@ -11,7 +11,7 @@ module mymod
      module procedure foo_1 ! { dg-error "must be INTENT" }
      module procedure foo_2 ! { dg-error "cannot be optional" }
      module procedure foo_3 ! { dg-error "must have, at most, two arguments" }
-     module procedure foo_1_OK
+     module procedure foo_1_OK  ! { dg-error "Ambiguous interfaces" }
      module procedure foo_2_OK
      function foo_chr (chr) ! { dg-error "cannot be assumed character length" }
        character(*) :: foo_chr
diff --git a/gcc/testsuite/gfortran.dg/generic_7.f90 b/gcc/testsuite/gfortran.dg/generic_7.f90
new file mode 100644 (file)
index 0000000..12cb9ae
--- /dev/null
@@ -0,0 +1,27 @@
+! { dg-do compile }
+! Tests the fix for PR29652, in which ambiguous interfaces were not detected
+! with more than two specific procedures in the interface.
+!
+! Contributed by Daniel Franke  <franke.daniel@gmail.com>
+!
+MODULE global
+INTERFACE iface
+  MODULE PROCEDURE sub_a
+  MODULE PROCEDURE sub_b ! { dg-error "Ambiguous interfaces" }
+  MODULE PROCEDURE sub_c
+END INTERFACE
+CONTAINS
+  SUBROUTINE sub_a(x)
+    INTEGER, INTENT(in) :: x
+    WRITE (*,*) 'A: ', x
+  END SUBROUTINE
+  SUBROUTINE sub_b(y)
+    INTEGER, INTENT(in) :: y
+    WRITE (*,*) 'B: ', y
+  END SUBROUTINE
+  SUBROUTINE sub_c(x, y)
+    REAL, INTENT(in) :: x, y
+    WRITE(*,*) x, y
+  END SUBROUTINE
+END MODULE
+! { dg-final { cleanup-modules "global" } }